赞
踩
我想将http://wsb.wuhan.gov.cn/html/friendly/201602/t20160203_45633.shtml这个网页里的表格数据用python爬取出来,并导入CSV表格文件,但是总是出错,求大神教我,代码如下
import requests import time import random import socket import http.client from bs4 import BeautifulSoup import csv def getContent(url , data = None): header={ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Encoding': 'gzip, deflate, sdch', 'Accept-Language': 'zh-CN,zh;q=0.8', 'Connection': 'keep-alive', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.235' } # request 的请求头 timeout = random.choice(range(80, 180)) while True: try: rep = requests.get
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。