Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

电影页面目前没法以非登陆状态抓取 #11

Closed
murdercdh opened this issue Aug 25, 2022 · 4 comments
Closed

电影页面目前没法以非登陆状态抓取 #11

murdercdh opened this issue Aug 25, 2022 · 4 comments

Comments

@murdercdh
Copy link

murdercdh commented Aug 25, 2022

def get_imdb_id(url):
    r = requests.get(url, headers={'User-Agent': USER_AGENT})
    soup = BeautifulSoup(r.text, 'lxml')
    info_area = soup.find(id='info')
    imdb_id = None
    try:
        if info_area:
            # 由于豆瓣页面更改,IMDB的ID处不再有链接更改查询方法
            for index in range(-1, -len(info_area.find_all('span')) + 1, -1):
                imdb_id = info_area.find_all('span')[index].next_sibling.strip()
                if imdb_id.startswith('tt'):
                    break
        else:
            print('不登录无法访问此电影页面:', url)
    except:
        print('无法获得IMDB编号的电影页面:', url)
    finally:
        return imdb_id if not imdb_id or imdb_id.startswith('tt') else None

难道要伪造ua和cookies才行么?

@fisheepx
Copy link
Owner

@murdercdh
有一些稍微限制级点的电影在不登录状态下是没有办法打开条目的。
但这些条目在已经登录状态下就可以打开,逻辑很迷。
程序没有登录逻辑,所以限制级只能自己手工导入了。

关于什么是限制级豆瓣并没有公开相关标准,这个登录提示不登录的无法打开的就是了。

@murdercdh
Copy link
Author

murdercdh commented Nov 2, 2022

@murdercdh 有一些稍微限制级点的电影在不登录状态下是没有办法打开条目的。 但这些条目在已经登录状态下就可以打开,逻辑很迷。 程序没有登录逻辑,所以限制级只能自己手工导入了。

关于什么是限制级豆瓣并没有公开相关标准,这个登录提示不登录的无法打开的就是了。

目前测试在200-300的连续请求以后,豆瓣的安全防火墙会无脑ban掉抓取ip,很弱智,就连登陆完毕的网页也一起banned掉了,我要迁移个数据感觉就很麻烦.

我找到一个他们自己爬了一些数据下来的query接口,但是却没有提供认证的姿势,也是郁闷了
https://github.com/iiiiiii1/douban-imdb-api

@fisheepx
Copy link
Owner

fisheepx commented Nov 7, 2022

豆瓣导出CSV时可以指定导出的开始日期,少量多次的分批导出也许可以。

@murdercdh
Copy link
Author

murdercdh commented Mar 22, 2023

已经导出完毕,现在我改了下程序,没有用随机代理和随机agent了(douban反扒,对于已经登陆用户,直接封24小时ip, 挺无聊的),直接每天跑一次,直到所有我自己片单都跑完,已经迁移到letterbox然后import到imdb了。

卸载douban app完毕

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants