User Agent to get source code from web

L

Legacy 185509

Guest
Hi,
I found this code online

but I have problem, I just do not want to pull source code.

I want to pull source code by changing setting User Agent.

Is there a way to get source code by changing User Agent to like iPhone or iPad via VBA?

Thanks

Code:
[FONT=Arial]Sub Tester() [/FONT]
[FONT=Arial]        Range("B2").Value = GetSource("[/FONT][URL="http://www.google.com/"]http://www.google.<wbr>com[/URL][FONT=Arial]") [/FONT]
[FONT=Arial]End Sub [/FONT]


[FONT=Arial]Function GetSource(sURL As String) As String [/FONT]

[FONT=Arial]Dim oXHTTP As Object [/FONT]

[FONT=Arial]    Set oXHTTP = CreateObject("MSXML2.XMLHTTP") [/FONT]
[FONT=Arial]    oXHTTP.Open "GET", sURL, False [/FONT]
[FONT=Arial]    oXHTTP.send [/FONT]
[FONT=Arial]    GetSource = oXHTTP.responsetext [/FONT]
[FONT=Arial]    Set oXHTTP = Nothing [/FONT]

[FONT=Arial]End Function[/FONT]
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,216,119
Messages
6,128,941
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top