Web Scraping - XPath

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
ricardo
Newbie
Posts: 2
Joined: Mon Dec 31, 2018 5:43 pm

Web Scraping - XPath

Post by ricardo » Mon Dec 31, 2018 5:59 pm

Hello and greetings.

I have the following script:
IETagEventByAttrib>http://www.buscacep.correios.com.br/sis ... ,,04115000
IETagEventByAttrib>http://www.buscacep.correios.com.br/sis ... scar,click,
Wait>1
IEWait>http://www.buscacep.correios.com.br/sis ... dereco.cfm

I would like to capture the result element named Logradouro/Nome: "<td width="150">Rua Pedro Pomponazzi&nbsp;</td>", which is related to the following XPath: /html/body/div[1]/div[3]/div[2]/div/div/div[2]/div[2]/div[2]/table/tbody/tr[2]/td[1]

In order to achieve my goal, which is the correct way to use IETagEventByAttrib? Can I use a XPath reference here?
Best

ricardo
Newbie
Posts: 2
Joined: Mon Dec 31, 2018 5:43 pm

Re: Web Scraping - XPath

Post by ricardo » Wed Jan 02, 2019 3:42 am

Hello,
Instead of using XPath, I found out another way to extract the desired element:
IEGetTagsByAttrib>{"http://www.buscacep.correios.com.br/sis ... valueArray

The valueArray_1 has the following content:
/*
<tbody><tr>
<th width="150">Logradouro/Nome:</th>
<th width="90">Bairro/Distrito:</th>
<th width="80">Localidade/UF:</th>
<th width="50">CEP:</th>
</tr>
<tr>
<td width="150">Rua Pedro Pomponazzi&nbsp;</td>
<td>Jardim Vila Mariana&nbsp;</td>
<td>São Paulo/SP&nbsp;</td>
<td width="55">04115-000</td>
</tr>
</tbody></table>
*/

Is there a MS (or VBScript) command to directly parse the 'cells' of my table?
Thanks

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Web Scraping - XPath

Post by Marcus Tettmar » Wed Jan 02, 2019 2:31 pm

I would use RegEx for this.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts