Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How do I pull variable URL from one column and download the contentto another column?

So, in column A I have an IP address. There will be many different
ones. I am trying to figure out the easiest and cleanest way to do
geolocation on the IP using this address (http://ipinfodb.com/
ip_query.php?ip=166.137.132.16) and have it update the IP address
based on the value in column A then put the output into columns B, C,
D (or whatever). Ideally I just want to get the Country, State and
City fields from the XML output.

Here is the XML output from the site:
166.137.132.16
OK
US
United States
34
New Jersey
New Milford
07646
40.933
-74.0177
-5.0
-4.0

Column 1
166.137.132.16
72.15.195.84
75.215.119.92
76.111.15.57
76.93.244.254
96.41.34.184
72.151.49.155


I have tried the Get External Data From Web but I have to do each one
manually. Any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default How do I pull variable URL from one column and download the conten

Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
BaseURL = "http://ipinfodb.com/ip_query.php?ip="
TempURL = Sheet1.Range("A1").value

objHTTP.setTimeouts 0, 0, 0, 0
URL = BaseURL & TempURL
objHTTP.Open "GET", URL, False
objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible;
MSIE 6.0; Windows NT 5.0)"
objHTTP.send ("")
SourceHTMLText = objHTTP.responseText

Put in a loop to grab your TempURL (IP addresses) from your sheet. Use the
returned SourceHTMLText to parse out the data elements you need. This works
for some pages, but YMMV as web pages that have embedded javascript elements,
etc may not always expose everything on the page as cleanly as one might like.

HTH,
Keth

"pand0ra.usa" wrote:

So, in column A I have an IP address. There will be many different
ones. I am trying to figure out the easiest and cleanest way to do
geolocation on the IP using this address (http://ipinfodb.com/
ip_query.php?ip=166.137.132.16) and have it update the IP address
based on the value in column A then put the output into columns B, C,
D (or whatever). Ideally I just want to get the Country, State and
City fields from the XML output.

Here is the XML output from the site:
166.137.132.16
OK
US
United States
34
New Jersey
New Milford
07646
40.933
-74.0177
-5.0
-4.0

Column 1
166.137.132.16
72.15.195.84
75.215.119.92
76.111.15.57
76.93.244.254
96.41.34.184
72.151.49.155


I have tried the Get External Data From Web but I have to do each one
manually. Any suggestions?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How do I pull variable URL from one column and download theconten

So I tried using the code and nothing happens. Any suggestions?


On Aug 20, 3:40*pm, ker_01 wrote:
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
BaseURL = "http://ipinfodb.com/ip_query.php?ip="
TempURL = Sheet1.Range("A1").value

* * * * objHTTP.setTimeouts 0, 0, 0, 0
* * * * * *URL = BaseURL & TempURL
* * * * * *objHTTP.Open "GET", URL, False
* * * * * *objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible;
MSIE 6.0; Windows NT 5.0)"
* * * * * *objHTTP.send ("")
* * * * SourceHTMLText = objHTTP.responseText

Put in a loop to grab your TempURL (IP addresses) from your sheet. Use the
returned SourceHTMLText to parse out the data elements you need. This works
for some pages, but YMMV as web pages that have embedded javascript elements,
etc may not always expose everything on the page as cleanly as one might like.

HTH,
Keth

"pand0ra.usa" wrote:
So, in column A I have an IP address. There will be many different
ones. I am trying to figure out the easiest and cleanest way to do
geolocation on the IP using this address (http://ipinfodb.com/
ip_query.php?ip=166.137.132.16) and have it update the IP address
based on the value in column A then put the output into columns B, C,
D (or whatever). Ideally I just want to get the Country, State and
City fields from the XML output.


Here is the XML output from the site:
166.137.132.16
* *OK
* *US
* *United States
* *34
* *New Jersey
* *New Milford
* *07646
* *40.933
* *-74.0177
* *-5.0
* *-4.0


Column 1
166.137.132.16
72.15.195.84
75.215.119.92
76.111.15.57
76.93.244.254
96.41.34.184
72.151.49.155


I have tried the Get External Data From Web but I have to do each one
manually. Any suggestions?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How do I pull variable URL from one column and download theconten

Ok, so I need some feedback on why my macro is not working.

I am pulling a URL from column C. Each row will have a different URL.
I want the macro to go through each row in column C and retrieve the
data from the URL and put it in the cell starting at column D. When I
run my macro nothing happens other then the cell D2 is selected.


Sub DownloadXML()
'
' DownloadXML Macro
'
' Keyboard Shortcut: Ctrl+h
'
' Select cell D2, *first line of data*.
Range("D2").Select

' Set Do loop to stop when an empty cell is reached.
Do Until IsEmpty(ActiveCell)

ActiveWorkbook.XmlMaps("Response_Map").Import Sheet1.Range
("$C2").Value

' Step down 1 row from present location.
ActiveCell.Offset(1, 0).Select

Loop

End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pull value from column heading Cecilia Excel Worksheet Functions 1 June 19th 07 12:37 AM
can vlookup pull from 2 columns into 1 column? jennifer Excel Worksheet Functions 4 May 11th 07 04:48 AM
copy a range with known start column to variable end column Matilda Excel Programming 2 August 2nd 06 04:55 PM
Offset from a variable column to a fixed column Kurt Barr Excel Programming 2 June 27th 06 05:45 PM
pull value from last cell in a column Bob Phillips[_5_] Excel Programming 2 July 17th 03 11:13 PM


All times are GMT +1. The time now is 03:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"