简体   繁体   中英

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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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