猫眼电影top100 是数据是在加载网页时直接就已经加载了的,所以可以通过requests.get()方法去获取这个url的数据,能过对得到的数据进行分析从而获得top100的数据, 把获取的数据存入本地文件中. 代码如下: import requests import re import json from multiprocessing import Pool #引用异常处理机制,这个类是所有异常类的超类,所以能全捕捉 from requests.exceptions import Requ
#requests+正则表达式提取猫眼电影top100 import requests import re import json from requests.exceptions import RequestException from multiprocessing import Pool def get_one_page(url): headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36
import json # from multiprocessing import Pool import requests from requests.exceptions import RequestException import re def get_one_page(url): try: headers={"user-agent":'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gec
'''Request+正则表达式抓取猫眼电影TOP100内容''' import requests from requests.exceptions import RequestException import re import json from multiprocessing import Pool #进程池 def get_one_page(url): try: reponse = requests.get(url) if reponse.status_code==200: return