[英]How to collect links from Instagram direct. Python + Selenium
I need to collect links of all chats in the instagram directory.我需要收集 instagram 目录中所有聊天的链接。 My idea is this - you need to write code in order to scroll through the entire direct to the bottom and collect links in parallel.我的想法是这样的——您需要编写代码才能直接滚动到底部并并行收集链接。 But I do not know how to do it correctly, I tried with javaScript but I am very clueless about it.但我不知道如何正确地做到这一点,我试过 javaScript 但我对此一无所知。 I thought maybe I can somehow catch on to the scroll- bar and then write '"click_and_hold("PAGE_DOWN")'" but I don't know how to cling to it, in general, tell me how to implement it.我想也许我可以以某种方式抓住滚动条然后写“click_and_hold(”PAGE_DOWN")'”但我不知道如何坚持它,一般来说,告诉我如何实现它。 My last try: xpath to the div'y responsible for the chat block.我最后一次尝试:xpath 给负责聊天块的 div'y。
direct_general_list = browser.find_element_by_xpath("/html/body/div[1]/section/div/div[2]/div/div/div[1]/div[3]/div")
while True:
direct_general_list.send_keys(Keys.PAGE_DOWN)
time.sleep(1)
general_path_block = browser.find_element_by_xpath("/html/body/div[1]/section/div/div[2]/div/div/div[1]/div[3]/div/div/div")
while True:
browser.execute_script("arguments[0].scrollTop = arguments[0].scrollTop + arguments[0].offsetHeight;", general_path_block)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.