当前位置:   article > 正文

Python爬取网页数据并导入表格_python shtml 抓取

python shtml 抓取

我想将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
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/599519
推荐阅读
相关标签
  

闽ICP备14008679号