马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
# -- coding: utf-8 --
'''
Created on 2018年08月07日
@author: huyw
'''
from bs4 import BeautifulSoup
import datetime
import urllib.request, urllib.parse, http.cookiejar
import xlsxwriter
# 定义解析网页函数
def getHtml(url):
cj=http.cookiejar.CookieJar()
opener=urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
# 伪装成浏览器,虽然并没啥卵用
opener.addheaders=[('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36'),('Cookie','4564564564564564565646540')]
urllib.request.install_opener(opener)
html_string = urllib.request.urlopen( url ).read()
return html_str