17 lines
596 B
Python
17 lines
596 B
Python
import requests
|
|
from bs4 import BeautifulSoup
|
|
|
|
url = "http://www.ishen365.com/index.php/article/18/show/28" # 黑木耳炒山药
|
|
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'
|
|
}
|
|
|
|
try:
|
|
response = requests.get(url, headers=headers)
|
|
response.encoding = 'utf-8'
|
|
with open("scraper/source_recipe_detail.html", "w", encoding="utf-8") as f:
|
|
f.write(response.text)
|
|
print("Saved recipe detail to scraper/source_recipe_detail.html")
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|