C#: How to extract data from selection using web browser control

  • Thread starter Thread starter Sudip_inn
  • Start date Start date
S

Sudip_inn

Guest
I have load a web site into my web browser control. user will select data from tabular data which i need to parse and populate in my data datagridview.

this is the web site from where i need to parse data from selection. see the url https://www.sec.gov/Archives/edgar/data/97210/000119312519143836/d717687d10q.htm#toc717687_3

see the screen shot where i have some selected text which i need to parse and load as data in datagridview.

1h284.png

i have done the code but not being able to extract data properly because i am extracting each line and then extracting each work by space. so where LI has space between then my idea is not working. so what would be best work out.

Net revenue is a name of LI which has space but it is a LI name. so how to parse if LI has space between but will be extracted as single word?

this code i have tried which is working partially

private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.
Navigate("10-Q");
}

private void button1_Click(object sender, EventArgs e)
{
dynamic document = webBrowser1.Document.DomDocument;
dynamic selection = document.selection;
dynamic text = selection.createRange().text;
var selectedtext = (string)text;

string[] stringSeparators = new string[] { "\r\n" };
string[] lines = selectedtext.Split(stringSeparators, StringSplitOptions.None);

foreach (string s in lines)
{
string sline = s;
string[] words = sline.Split('\t');
string Li = words[0];
string value1 = words[1];
string value2 = words[2];
//Debug.WriteLine(s);
}


just tell me what logic i should used as a result LI name should be extracted as a single word even if there is space. as example Net Revenue is LI name.

numeric value will be extracted as single value. if my objective is clear then please help with idea & sample code. thanks

Continue reading...
 
Back
Top