首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >python爬虫解压缩url不工作

python爬虫解压缩url不工作
EN

Stack Overflow用户
提问于 2016-03-23 03:34:01
回答 1查看 119关注 0票数 0

我尝试用imdb包编写一个简单的python程序,从他们的数据库中提取电影信息,但是我不知道为什么代码返回空列表。我的猜测是我提取url信息的方式(通过使用(.*?))从网站上看是错的。我想从网页中提取一个网址链接。这是密码。谢谢!

代码语言:javascript
复制
import urllib
import re
import imdb
imdb_access = imdb.IMDb()

top_num = 5

movie_list = ["The Matrix","The Matrix","The Matrix","The Matrix","The Matrix"]


for x in xrange(0,top_num):
    contain = imdb_access.search_movie(movie_list[x])

    ID = contain[0].movieID #str type

    htmltext = (urllib.urlopen("http://www.imdb.com/title/tt0133093/?ref_=nv_sr_1")).read()
    # a pattern in the website
    regex = regex = '<img alt="The Matrix Poster" title="The Matrix Poster" src="(.*?)" itemprop="image">'
    pattern = re.compile(regex)
    #print (str((pattern)))
    result = re.findall(pattern,htmltext)
    print result 
    #print type(htmltext)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-23 04:08:20

我认为问题在于你能有新的行吗(.*\n*.*?)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36169342

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档