test webscrapping
This commit is contained in:
parent
0262e99d22
commit
64118a3c20
15
web_scrap.py
15
web_scrap.py
@ -3,10 +3,17 @@
|
|||||||
# Python 3
|
# Python 3
|
||||||
# Extraction des liens d'une page web
|
# Extraction des liens d'une page web
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import urllib.request
|
import requests
|
||||||
|
|
||||||
with urllib.request.urlopen('https://www.clarissariviere.com/') as response:
|
page = requests.get("https://www.clarissariviere.com")
|
||||||
webpage = response.read()
|
|
||||||
soup = BeautifulSoup(webpage, 'html.parser')
|
if page.status_code == 200:
|
||||||
|
soup = BeautifulSoup(page.text, 'html.parser')
|
||||||
for anchor in soup.find_all('a'):
|
for anchor in soup.find_all('a'):
|
||||||
print(anchor.get('href', '/'))
|
print(anchor.get('href', '/'))
|
||||||
|
#with urllib.request.urlopen('https://www.clarissariviere.com/index.html') as response:
|
||||||
|
# print(response)
|
||||||
|
#webpage = response.read()
|
||||||
|
#soup = BeautifulSoup(webpage, 'html.parser')
|
||||||
|
#for anchor in soup.find_all('a'):
|
||||||
|
# print(anchor.get('href', '/'))
|
Loading…
x
Reference in New Issue
Block a user