I want to scroll through the page and press the button while crawling using selenium

Asked 2 years ago, Updated 2 years ago, 48 views

I'd like to get the webtoon details of Kakao webtoon.

However, to view detailed information, you must enter the webtoon list and scroll through the page to create a work information button.

When you run it as below, it scrolls down but the button is not visible.

from selenium import webdriver
import time

driver = webdriver.Firefox(capabilities=None, executable_path='driver path') #webdriver

driver.get('https://webtoon.kakao.com/content/%EB%B0%94%EB%8B%88%EC%99%80-%EC%98%A4%EB%B9%A0%EB%93%A4/1781') #kakaowebtoon link
time.sleep(2)

options = driver.find_element_by_xpath("//div[@id='root']/main/div/div/div/div[1]/div[3]/div/div/div[1]/div/div[2]/div/div[1]/div/div/div/div")
driver.execute_script("arguments[0].scrollIntoView(true);",options) #scroll down
time.sleep(1)

#driver.execute_script ("window.scrollTo(0,900)") #Not scrolled

How can I press the Details button?

Webtoon link

selenium python

2022-09-20 15:31

1 Answers

Do we need to use selenium?

import requests

url = 'https://gateway-kw.kakao.com/decorator/v1/decorator/contents/2119/profile'
with requests.get(url) as r:
    print(r.text)


2022-09-20 15:31

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.