一、安装套件
1、pip install requests
2、pip install BeautifulSoup4
二、剖析网页元素
soup = BeautifulSoup(reshtml,'html.parser').select('.news-item')
三、安装数据库
1、pip install pymysql
四、python爬虫示例
from bs4 import BeautifulSoup
import requests
import pymysql
import logging
import json
import re
def getnewsinfo(url):
res = requests.get(url)