第77章 爬虫抓取的第一份数据:教辅价格 (2 / 8)
第二、三天:编写第一个爬虫脚本(京东)。
他先尝试抓取单页数据。代码大致如下:
import requests
from bs4 import BeautifulSoup
import pandas as pd
import time
headers = {'User-Agent': 'Mozil/5.0...'} # 模拟浏览器请求头
url = 'https://search.jd./...初中数学 教辅...' # 搜索URL
response = requests.get(url, headers=headers)
soup = BeautifulSoup(respoext, 'html.parser')
books = []
The content is not finished, continue reading on the next page