lundi 29 juillet 2019

how to grap data from a local website with python

I need a hint how to grap data from a website. I am quite new to web grapping. The special thing is that I have no access to the website because it runs locally on another network. For development I only have the website as an html file. Know my problem is that I get an error with my following code. I think the problem is quite simple but I do not have an idea so far.

import requests
import urllib.request
import time
from bs4 import BeautifulSoup

url = 'file:///tmp/mozilla/LiveData.html' # file is locally so far
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")

I get the following error: NewConnectionError: : Failed to establish a new connection: [Errno -2] Name or service not known

Maybe it does not work when it is local and not a "real" website. Thanks for any help!




Aucun commentaire:

Enregistrer un commentaire