first commit
This commit is contained in:
commit
f739ac4611
|
@ -0,0 +1,33 @@
|
||||||
|
import requests
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
# Define the URL
|
||||||
|
url = 'https://dictionary.cambridge.org/dictionary/essential-american-english/wrist'
|
||||||
|
|
||||||
|
# Define the proxy settings
|
||||||
|
#proxies = {
|
||||||
|
# 'http': 'http://127.0.0.1:10809',
|
||||||
|
# 'https': 'http://127.0.0.1:10809'
|
||||||
|
#}
|
||||||
|
headers = {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
|
||||||
|
}
|
||||||
|
response = requests.get(url, headers=headers)
|
||||||
|
|
||||||
|
|
||||||
|
# Check if the request was successful
|
||||||
|
if response.status_code == 200:
|
||||||
|
# Parse the content with BeautifulSoup
|
||||||
|
soup = BeautifulSoup(response.content, 'html.parser')
|
||||||
|
|
||||||
|
# Find the meta description tag
|
||||||
|
meta_description = soup.find('meta', attrs={'name': 'description'})
|
||||||
|
|
||||||
|
if meta_description:
|
||||||
|
# Extract the content attribute
|
||||||
|
description_content = meta_description.get('content')
|
||||||
|
print(description_content)
|
||||||
|
else:
|
||||||
|
print("Meta description tag not found.")
|
||||||
|
else:
|
||||||
|
print(f"Failed to retrieve the page. Status code: {response.status_code}")
|
Loading…
Reference in New Issue