0

I am trying to submit a form, which is practically using a shipping company's website, submitting a tracking number and getting the result so that I can use beautifulsoup eventually to get the data I need. When I try this manually it returns the data, but with the python code it returns an non-formatted page and the data I need is not there as if the query was not executed. It returns

Your Current Browser Is Not Supported !

which cannot be true since I am using the latest Google Chrome v.60

Where is the problem with the code?

code:

import requests
import webbrowser
from bs4 import BeautifulSoup

url = "https://www.nykline.com/ecom/CUP_HOM_3000.do?redir=Y"
payload = {'cargoTrackingNo':'TEMU9538796'}

r = requests.get(url, params=payload)
with open("results.html", "wb") as f:
    f.write(r.content)


webbrowser.open("results.html")
Ibo
  • 4,081
  • 6
  • 45
  • 65
  • 3
    I don't understand your comment. You're *not* using Google Chrome, you're using `requests`. And you've commented out the line where you set the header which attempts to spoof the user-agent. – Daniel Roseman Sep 07 '17 at 19:45
  • Can you submit the form in a browser with JavaScript turned off? if not it is a no JavaScript issue. or it could be a cookie issue if it works with JavaScript off – Dan-Dev Sep 07 '17 at 20:05
  • @DanielRoseman Let's forget about the `headers` line (I deleted it from the code). I use `requests` to get the job done and my default browser is Chrome. You can run the code and compare it to what it is returned when doing this manually in the browser. – Ibo Sep 07 '17 at 20:13
  • @DanDev I turned off the JavaScript on Chrome and the `Track` button did not work, so it did not go to the response page. How can I solve this? – Ibo Sep 07 '17 at 20:16
  • see my answer to https://stackoverflow.com/questions/45259232/scraping-google-finance-beautifulsoup/ – Dan-Dev Sep 07 '17 at 20:30

0 Answers0