Search web source code for specific string

K

k3holdings

Hey all,

I am trying to figure out how to search the source code of any website
for a specified string and return the next 14 characters back into a
cell.

In this particular instance I need to:

Search for "PARCEL="
Return "22042040150000" into cell A1

But I would like to know how to find any string in th source code.

Any help would be greatly appreciated.

Thanks,
Kyle
 
K

k3holdings

It's actually not. Right now I do a lot of copying and pasting to get
the info I need. I am just working on a routine that automates this
for me.
Right now not knowing how to do this is hacking. That is hacking into
my time.
 
J

JLGWhiz

Then you probably didn't really mean to use "source code" as the description
of what you are after. Source code is the underlying code for the operation
of a web site.
 
K

k3holdings

I mean when I am in internet explorer and select view > source from
the menu bar, which brings up the HTML code.
 
K

k3holdings

Is there anyone that has any ideas. Anything to even point me in the
right direction.
 
R

ron

Hey all,

I am trying to figure out how to search the source code of any website
for a specified string and return the next 14 characters back into a
cell.

In this particular instance I need to:

Search for "PARCEL="
Return "22042040150000" into cell A1

But I would like to know how to find any string in th source code.

Any help would be greatly appreciated.

Thanks,
Kyle

Kyle...This should do what you want, just insert your url..ron

Sub Search_SourceCode()
' Get the source code from the web page
my_url = "http://yoururl.com"
Set my_obj = CreateObject("MSXML2.XMLHTTP")
my_obj.Open "GET", my_url, False
my_obj.send
my_var = my_obj.responsetext
Set my_obj = Nothing

' Find search term and assign next 14 characters to a variable
my_term = "Parcel="
pos_1 = InStr(my_var, my_term)
next14 = Mid(my_var, 7 + pos_1, 14)

'Paste to worksheet
Range("A1").Select
activecell = next14
End sub
 
K

k3holdings

Hey Ron,

Thanks for your response, this definitly pointed me in the right
direction. I appreciate your help.

Thanks,
Kyle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top