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

**获取到搜索的input框后需要先.click()然后再.send_keys()** #58

Open
Ju0724 opened this issue Aug 8, 2022 · 2 comments
Open

Comments

@Ju0724
Copy link

Ju0724 commented Aug 8, 2022

获取到搜索的input框后需要先.click()然后再.send_keys()

`def search():
try:
print('start visit bilibili...')
browser.get('https://www.bilibili.com/')

    search_input = WAIT.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#nav-searchform > div.nav-search-content > input")))
    search_input.click()
    search_input.send_keys('蔡徐坤篮球')
    search_submit = WAIT.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="nav-searchform"]/div[2]')))
    search_submit.click()
    print('jump to new window')
    all_h = browser.window_handles
    browser.switch_to.window(all_h[1])
except TimeoutException:
    return search()`

Originally posted by @ls-6414 in #6 (comment)

@856tangbin
Copy link

856tangbin commented Aug 8, 2022 via email

@Ju0724
Copy link
Author

Ju0724 commented Aug 8, 2022

这个还是不行啊,搜索进去之后,就会刷新到主页,一直重复,而不是直接进入下一页开始爬取内容

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