Hi
I am developing some SEO tools and am using importXML and Xpath queries to pull the information I want.
(long time since I have posted here I'm an active member over on SEO Chat as tstolber)
Code:
=importxml(B1,"//div[@class='intro-box-wide']//li/a/@href")
Where B1 is the URL of the page I am analyzing. The final solution will be to pull specific data for multiple records returned from another function.
I am looking at URLs like
http://whois.domaintools.com/devshed.com
and I want to pull the following data from the code via import XML using the Xpath query. I am having trouble with getting the syntax right for Xpath.
I would like to get the IP address, country, city and network.
Code:
<div id="ssTab-ipAddress" class="float-row display-input">
<div class="add-to-my-whois" title="Add to My Whois" style="display:none;"><span onclick="addMyWhoisContent('ssTab-ipAddress','IP Address');"></span></div>
<div class="form-label field-label wide-20"><span>IP Address:</span></div>
<div class="form-field wide-80 normal">
<a class="left-pad-none bold" href="http://whois.domaintools.com/209.35.17.17">209.35.17.17</a>
<a class="left-pad-none horiz-marg-10" href="http://www.domaintools.com/research/reverse-ip/?hostname=209.35.17.17">Reverse-IP</a> |
<a class="left-pad-none horiz-marg-10" href="http://www.domaintools.com/research/ping/?query=209.35.17.17">Ping</a> |
<a class="left-pad-none horiz-marg-10" href="http://www.domaintools.com/research/dns/?query=209.35.17.17">DNS Lookup</a> |
<a class="left-pad-none horiz-marg-10" href="http://www.domaintools.com/research/traceroute/?query=209.35.17.17">Traceroute</a>
</div>
</div>
and
Code:
<div id="ssTab-ipLocation" class="float-row display-input">
<div class="add-to-my-whois" title="Add to My Whois" style="display:none;"><span onclick="addMyWhoisContent('ssTab-ipLocation','IP Location');"></span></div>
<div class="form-label field-label wide-20"><span>IP Location:</span></div>
<div class="form-field wide-80">
<img src="/images/flags/us.gif" alt="United States" height="12" width="18">
- Washington - Woodinville - Peer 1 Dedicated Hosting </div>
I can see that the IP address is in an A element with the class "left-pad-none bold" and the country is in an IMG element within a DIV with the class "form-field wide-80" with the ALT text being the country name. Then the text immediately after that gives the city and then the network name of the hosting platform.
I am struggling to get the right syntax for the Xpath query. I have some XPath queries that work in my Import XML but I am really struggling to pull this data.
Any help is appreciated.
Thanks!