简体   繁体   English

使用 selenium 在论坛上搜索搜索栏 - 每次都会自动打开网站的 google chrome 页面

[英]using selenium to search a search bar on forums - automatically opens google chrome page of website each time

def getUserPage(user):  

    d = webdriver.Chrome()
    d.get(url here)
    e = d.find_element_by_name('username')
    e.send_keys(user)
    e.send_keys(Keys.ENTER)
    return d.current_url

(in a discord.py bot) that's my code to get the given user's profile page URL and I have another function which webscrapes that URL to give some information. (在 discord.py bot 中)这是我获取给定用户的个人资料页面 URL 的代码,我还有另一个功能可以抓取该 URL 以提供一些信息。 but whenever I or any other user runs the command $profile username it opens up the google chrome page with the website then does the web scraping and shows the information in discord.但是每当我或任何其他用户运行命令 $profile username 时,它​​都会打开带有网站的谷歌浏览器页面,然后进行网络抓取并显示不一致的信息。 is there a way to disable it automatically opening a google chrome page of the website for me and anyone else using the bot?有没有办法禁用它自动为我和其他使用机器人的人打开网站的谷歌浏览器页面?

I have done that before.我以前这样做过。 If you do it on localhost (aka your own computer) it will pop up.如果您在本地主机(也就是您自己的计算机)上执行此操作,它将弹出。 However, if you use a host ,for example Replit, it will not open up.但是,如果您使用主机,例如 Replit,它将无法打开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM