ani01104 / selenium-vba

Automatically exported from code.google.com/p/selenium-vba
0 stars 0 forks source link

extract product data from web #127

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Operating system : windows 7
.Net Framework version :  4.0
Office Version : 2007
SeleniumWrapper version : latest

What is your issue ?
Hi guys,

Pls suggest me
 I want to extract product data from this link like url, model number, category , description and upc number.  Also pls suggest me how can i impliment this in vb instead of excel macros.
http://www.l-com.com/usb-usb-connectors-and-hoods-type-a-and-b_mobi

Pls help me this could be helps allot for me.

Original issue reported on code.google.com by arunbana...@gmail.com on 1 Jan 2015 at 9:03

GoogleCodeExporter commented 9 years ago
VBS is similar to VBA.
The main differences are that VBS doesn't support the "New" statement and that 
only the variant data type is supported.

An example in your case:

'Create an Excel Workbook
Set xl = CreateObject("Excel.Application")
xl.Visible = true
Set ws = xl.Workbooks.Add().Worksheets(1)

'Open the browser and find elements
Set wd = CreateObject("SeleniumWrapper.WebDriver")
wd.start "firefox", "http://www.l-com.com/"
wd.open "/usb-usb-connectors-and-hoods-type-a-and-b_mobi"
Set elts = 
wd.findElementsByCssSelector("tbody>tr>td>table>tbody>tr:nth-child(2)>td")

'Fill the workbook
For i=0 to elts.Count 
    ws.Cells(i+1, 1) = elts(i).Text
Next

Original comment by florentbr on 5 Jan 2015 at 11:17

GoogleCodeExporter commented 9 years ago
Hi,

Iam getting error as below

"Index was out of range. Must be non-negative and less than the size of
the collection.
Parameter name: index"

And can u pls suggest me how can i add SeleniumWrapper reference to VB windows 
applications..?

Original comment by arunbana...@gmail.com on 8 Jan 2015 at 10:16

GoogleCodeExporter commented 9 years ago
>Index out of range...
My bad, the elements collection is a zero based index (will be 1 based in the 
next release):
For i=1 to elts.Count 
    ws.Cells(i, 1) = elts(i - 1).Text
Next

>add SeleniumWrapper reference to VB windows applications..
What are you trying to achieve exactly here?

Original comment by florentbr on 9 Jan 2015 at 10:50

GoogleCodeExporter commented 9 years ago
Hi, 

Thanks for your fast reply.
My requirement is simple.

Goto “http://www.l-com.com/usb-usb-connectors-and-hoods-type-a-and-b_mobi”
Collect all sub categories with links
And click on that (appears Product Page)
Collect Model Number, UPC number and Description of product.

And one of my friend asked the question as “is this possible to add 
SeleniumWrapper reference” in VB windows applications..?

Please check the screenshot, excel should look like that.

Original comment by arunbana...@gmail.com on 9 Jan 2015 at 11:13

Attachments:

GoogleCodeExporter commented 9 years ago
Regarding your requirements, you should find all the categories in the page, 
then click on each one and find all the items and loop over each one to fill an 
Excel sheet.

Now regarding your question "add SeleniumWrapper reference to VB windows 
applications...", I asked what you're trying to achieve as there is no such 
thing as "VB windows applications" in VBA and VBS.
SeleniumWrapper can be added to a workbook as a reference in the VBA IDE and 
then called in a module, class or form.
Could it be that you are talking about a standalone .Net or VB6 application 
created in Visual Studio?

Original comment by florentbr on 9 Jan 2015 at 12:01

GoogleCodeExporter commented 9 years ago
Hi,

Yes, it need for standalone .Net/VB6 application in Visual Studio.

Thanks

Original comment by arunbana...@gmail.com on 10 Jan 2015 at 1:15

GoogleCodeExporter commented 9 years ago
In that case you should use the Selenium .Net WebDriver from the official 
website:
http://www.seleniumhq.org/download/

The .Net WebDriver is name "C#" but can also be referenced and used in a VB.net 
project.

Original comment by florentbr on 10 Jan 2015 at 3:06