Retrieving data from a website using Visual Basic

On this website, we buy widgets that provide details for each of its parts on its own web page. Example: http://www.digikey.ca/product-search/en?lang=en&site=ca&KeyWords=AE9912-ND . I must find all of their parts that are in our database and add their values ​​to the Factory and Production numbers.

I was told that there is an opportunity for Visual Basic to access a web page and extract information. If someone can point me in the right direction, where to start, I'm sure I can figure it out.

Thank.

+5
source share
2 answers

-, HTMLAgilityPack (VB.Net)

, htmlagilitypack - . , Regex. , .

htmlagilitypack * dll , htmlagilitypack nuget . Chrome, , , . , , , ( HTML ).

"". XPath ( htmlagilitypack , ), . , , , XPath. ...

//*[@id="pricing"]

, XPath, Chrome, . , - , . "id", - .

XPath - , , . , , tbody, tr td-. HtmlAgilitypack , . XPath...

//*[@id='pricing']/tr/td

XPath , , tr td. ...

Dim Web As New HtmlAgilityPack.HtmlWeb
Dim Doc As New HtmlAgilityPack.HtmlDocument
Doc = Web.Load("http://www.digikey.ca/product-search/en?lang=en&site=ca&KeyWords=AE9912-ND")
For Each table As HtmlAgilityPack.HtmlNode In Doc.DocumentNode.SelectNodes("//*[@id='pricing']/tr/td")

Next

, , , .

Dim Web As New HtmlAgilityPack.HtmlWeb
Dim Doc As New HtmlAgilityPack.HtmlDocument
Doc = Web.Load("http://www.digikey.ca/product-search/en?lang=en&site=ca&KeyWords=AE9912-ND")
For Each table As HtmlAgilityPack.HtmlNode In Doc.DocumentNode.SelectNodes("//*[@id='pricing']/tr/td")
    MsgBox(table.InnerText)
Next

, ... , . , .

: Doc, , , , , . , , , , .

. . !

+5

Html Agility Pack !

Html Agility Pack (HAP)?

HTML-, DOM / XPATH XSLT ( XPATH XSLT, , ...). .NET-, " " HTML . " " HTML. System.Xml, HTML ( ).

, , HTML5 Microdata . CodePlex , : MicroData Parser

0

All Articles