Page 1 of 1

Web Cookies

Posted: Saturday 16th March 2024 12:08pm
by cogier
Does anybody know how to deal with web cookies. If I navigate to Google Maps and select 'Accept All' button, how do I prevent having to do this every time the program runs? I have attached a little program that will stop after you click the 'Accept All' button and the screen has finished displaying the map, but there are no cookies!
WebCookies-0.0.1.tar.gz
(7.83 KiB) Downloaded 65 times

Re: Web Cookies

Posted: Saturday 16th March 2024 1:35pm
by BruceSteers
hmm can't figure that one out m8, cookies seem to remain null.

But i figured out a bypass.

I tried to download the url using HttpClient.Download() then the text i got was a page saying "Page moved to <url>" and clicking that url showed the page without the cookie request.
With this URL...
https://consent.google.com/ml?continue= ... l=en&src=1

So i broke down the url to make the following function that you can pass the map coords to..


Public Sub Form_Load()

  WebView1.Url = GetMappAdress("50.6945657,-1.2873369,12z")

End

Public Sub GetMappAdress(Address As String) As String
  
  Return "https://consent.google.com/ml?continue=https://www.google.com/maps/@" & 
  Address & 
  "&gl=GB&m=0&pc=m&uxe=eomtm&cm=2&hl=en&src=1"
  
End


That now loads the map and does not ask for cookie consent.

Ps. i tried playing around removing some of the url post fields "&gl=GB&m=0&pc=m&uxe=eomtm&cm=2&hl=en&src=1" but any changes seemed to break it.

Re: Web Cookies

Posted: Saturday 16th March 2024 1:43pm
by cogier
Thanks, Bruce. I'll check it out.

Re: Web Cookies

Posted: Saturday 16th March 2024 1:49pm
by BruceSteers
Ps. you can see my house from there ;) lol

Re: Web Cookies

Posted: Saturday 16th March 2024 2:06pm
by BruceSteers
Here's a different version that may work better in other locations as i'm not sure how important the properties of the post args are.

This version does in code what i originally did, it uses HttpClient.Download to fetch the url and then extracts the link from the page...


Public Sub Form_Open()

  Me.H = Desktop.H
  Me.W = Desktop.W / 2
  Me.X = Desktop.W / 2
  Me.Y = 0

  WebView1.Url = GetMappAdress("https://www.google.com/maps/@50.6945657,-1.2873369,12z")

End

Public Sub GetMappAdress(Address As String) As String

  Dim sHtml As String = HttpClient.Download(Address)  ' get the page

  Dim iStartPos As Integer = InStr(sHtml, "HREF=\"") + 6  ' extract the link
  sHtml = Mid(sHtml, iStartPos, InStr(sHtml, "\">", iStartPos) - iStartPos)

  sHtml = Replace(sHtml, "amp;", "") ' convert &amp; to just &

  Return sHtml

End