Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8082

Troubleshooting • Re: Unable to connect to one website

$
0
0
Credit : https://scrapeops.io/python-web-scraping-playbook/python-requests-fake-user-agents

Code:

import requestsheaders={"User-Agent": "Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"}r = requests.get("http://www.waitrose.com", headers=headers)print(r.content)

Code:

pi@Pi4B:/tmp $ python scrape.py > xyzzy.htmpi@Pi4B:/tmp $ python scrape.pyb'<!doctype html>\n<html lang="en-GB" >\n<head>\n  <link rel="icon"  ...
That 'xyzzy.htm' is 2.5 MB with plenty of mentions of "waitrose" so hopefully one step forward.

Statistics: Posted by hippy — Sat Jun 14, 2025 1:40 am



Viewing all articles
Browse latest Browse all 8082

Trending Articles