chuanchanye8068 2017-11-12 04:38 采纳率: 0%
浏览 19864

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条回答 默认 最新

  • devmiao 2017-11-12 07:57
    关注
    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型