ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search web source code for specific string (https://www.excelbanter.com/excel-programming/419194-search-web-source-code-specific-string.html)

[email protected]

Search web source code for specific string
 
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

JLGWhiz

Search web source code for specific string
 
Sounds a lot like hacking to me.

" wrote:

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


[email protected]

Search web source code for specific string
 
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.

JLGWhiz

Search web source code for specific string
 
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.

" wrote:

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.


[email protected]

Search web source code for specific string
 
I mean when I am in internet explorer and select view source from
the menu bar, which brings up the HTML code.

[email protected]

Search web source code for specific string
 
Is there anyone that has any ideas. Anything to even point me in the
right direction.

ron

Search web source code for specific string
 
On Oct 28, 7:33*pm, wrote:
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


[email protected]

Search web source code for specific string
 
Hey Ron,

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

Thanks,
Kyle


All times are GMT +1. The time now is 01:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com