chuanchanye8068
chuanchanye8068
采纳率0%
2017-11-12 04:38 阅读 19.1k

python3.5错误'module' object is not callable

(1)
import urllib.request
from cons import headers

def getUrlList():
req=urllib.request('https://mm.taobao.com/tstar/search/tstar_model.do?_input_charset=utf-8')
req.add_header('user-agent',headers())

print (headers())

html=urllib.urlopen(req,
data='q&viewFlag=A&sortType=default&searchStyle=&searchRegion=city%3A&searchFansNum=&currentPage=1&pageSize=100').read()
print (html)

getUrlList()

(2)
import random

headerstr='''Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)'''

def headers():
header=headerstr.split('\n')
length=len(header)
return header[random.randint(0,length-1)]

运行(1)
产生错误如下:
D:\programmingtools\anaconda\python.exe D:/programmingtools/pycharmpro/files/201711112013/taobeauty.py
Traceback (most recent call last):
File "D:/programmingtools/pycharmpro/files/201711112013/taobeauty.py", line 13, in
getUrlList()
File "D:/programmingtools/pycharmpro/files/201711112013/taobeauty.py", line 6, in getUrlList
req=urllib.request('https://mm.taobao.com/tstar/search/tstar_model.do?_input_charset=utf-8')
TypeError: 'module' object is not callable

Process finished with exit code 1

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

相关推荐