Action
crawlist内置了几个网页行为,使您更容易操作网页。您可以在pre_load中使用Action。
action的种类
我们实现了7种action
import crawlist as cl
action = cl.Action
action.click(...args)
action.inputKeyword(...args)
action.sendEnter(...args)
action.switchLastTab(...args)
action.switchTab(...args)
action.searchRedirect(...args)
action.redirect(...args)
什么是 pre_load?
pre_load用于动态翻页,以便在分析器工作之前进行网页交互。
import crawlist as cl
class MyPager(cl.DynamicLineButtonPager):
def pre_load(self, webdriver: WebDriver = None) -> None:
webdriver.get("https://kuaixun.eastmoney.com/")
cl.Action.click(webdriver, '/html/body/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[3]/label/span[1]')
action的参数
methods
parms
click
driver – selenium webdriver
xpath – Click on the xpath path of the button
inputKeyword
driver – selenium webdriver
xpath – The xpath path of the input box keyword – keyword needs to be passed in
sendEnter
driver– selenium webdriver
xpath – The xpath path of the input box
switchLastTab
driver – selenium webdriver
switchTab
driver – selenium webdriver
index – The index handle
searchRedirect
driver – selenium webdriver
url – Link containing %s
keyword – keyword needs to be passed in
redirect
driver – selenium webdriver
url – Links that require redirection
最后更新于