如何解决Selenium异常:“无效参数“url”必须是字符串”

2024-05-19 18:42:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用python的insta scrape库,特别是获取instagram概要文件的所有帖子的方法

这是指向库页面的链接: https://pypi.org/project/insta-scrape/

这是指向图书馆文档的链接,特别是对于方法get_posts: https://instascrape.readthedocs.io/en/latest/instascrape.scrapers.html#module-instascrape.scrapers.profile

我的简单代码是:

options = Options()
options.add_argument('--headless')
driver = webdriver.Chrome(options=options)
insta_profile = Profile('https://www.instagram.com/molteni_matteo/')
insta_profile.scrape()
list_post = insta_profile.get_posts(webdriver=driver, amount=None,
                                      login_first=False, login_pause=60,
                                      max_failed_scroll=300, scrape=False, scrape_pause=5)
for profile_post in list_post:
    print(profile_post)

但它给了我一个错误:

error

我怎样才能解决这个问题


Tags: 方法httpsget链接driverprofilepostinstagram
1条回答
网友
1楼 · 发布于 2024-05-19 18:42:30

这实际上是python模块中的一个bug,Profile不能正确地接受url。 您可以通过设置

insta_profile.url = 'https://www.instagram.com/molteni_matteo/'

在调用get_posts之前

相关问题 更多 >