Script:
[
{
“type”: “newPage”,
“config”: {}
},
{
“type”: “gotoUrl”,
“config”: {
“url”: “https://www.pk42jobs.com/2023/11/kurulus-osman-season-5-episode-138_51.html”,
“timeout”: 30000,
“remark”: “”
}
},
{
“type”: “waitTime”,
“config”: {
“timeoutType”: “randomInterval”,
“timeout”: 700,
“timeoutMin”: 4587,
“timeoutMax”: 5987,
“remark”: “”
}
},
{
“type”: “inputContent”,
“config”: {
“selector”: “[data-id=’search-query’]”,
“selectorType”: “selector”,
“element”: “”,
“serial”: 1,
“intervals”: 300,
“content”: “watch”,
“isRandom”: “0”,
“randomContent”: “watch\r\nflower\r\nlightning\r\ntools”,
“remark”: “”,
“serialType”: “fixedValue”,
“serialMin”: 1,
“serialMax”: 50
}
},
{
“type”: “waitTime”,
“config”: {
“timeoutType”: “randomInterval”,
“timeout”: 226,
“timeoutMin”: 1145,
“timeoutMax”: 1598,
“remark”: “”
}
},
{
“type”: “waitForSelector”,
“config”: {
“selector”: “[data-results-grid-container]>li”,
“serial”: 3,
“isShow”: “1”,
“timeout”: 30000,
“remark”: “”
}
},
{
“type”: “scrollPage”,
“config”: {
“distance”: 666,
“type”: “smooth”,
“scrollType”: “position”,
“position”: “middle”,
“remark”: “”,
“rangeType”: “window”,
“selectorRadio”: “CSS”,
“selector”: “”,
“serial”: 1
}
},
{
“type”: “forTimes”,
“config”: {
“times”: 3,
“variableIndex”: “for_times_index”,
“remark”: “”,
“children”: [
{
“type”: “waitTime”,
“config”: {
“timeoutType”: “randomInterval”,
“timeout”: 514,
“timeoutMin”: 7845,
“timeoutMax”: 8874,
“remark”: “”
}
},
{
“type”: “scrollPage”,
“config”: {
“distance”: 635,
“type”: “smooth”,
“scrollType”: “position”,
“position”: “bottom”,
“remark”: “”,
“rangeType”: “window”,
“selectorRadio”: “CSS”,
“selector”: “”,
“serial”: 1
}
},
{
“type”: “waitTime”,
“config”: {
“timeoutType”: “randomInterval”,
“timeout”: 456,
“timeoutMin”: 4500,
“timeoutMax”: 5412,
“remark”: “”
}
},
{
“type”: “forTimes”,
“config”: {
“times”: 4,
“variableIndex”: “for_times_index”,
“remark”: “”,
“children”: [
{
“type”: “waitTime”,
“config”: {
“timeoutType”: “randomInterval”,
“timeout”: 515,
“timeoutMin”: 2512,
“timeoutMax”: 3542,
“remark”: “”
}
}
]
}
},
{
“type”: “scrollPage”,
“config”: {
“distance”: 0,
“type”: “smooth”,
“scrollType”: “position”,
“position”: “top”,
“remark”: “”,
“rangeType”: “window”,
“selectorRadio”: “CSS”,
“selector”: “”,
“serial”: 1
}
},
{
“type”: “waitTime”,
“config”: {
“timeoutType”: “randomInterval”,
“timeout”: 545,
“timeoutMin”: 1052,
“timeoutMax”: 2142,
“remark”: “”
}
},
{
“type”: “scrollPage”,
“config”: {
“distance”: 0,
“type”: “smooth”,
“scrollType”: “position”,
“position”: “top”,
“remark”: “”
}
}
]
}
},
{
“type”: “waitTime”,
“config”: {
“timeoutType”: “randomInterval”,
“timeout”: 299,
“timeoutMin”: 1000,
“timeoutMax”: 1598,
“remark”: “”
}
},
{
“type”: “closePage”,
“config”: {}
}
]
Playwright Scrolling
Creating a script for power scrolling through ads can be useful for testing or data collection purposes. Depending on the website and the technology stack used, different tools and methods can be employed. One popular approach is to use automation tools like Playwright, Selenium, or Puppeteer.
Here’s an example of how you might create a power scrolling script using Playwright in Python:
Playwright Script for Power Scrolling
from playwright.sync_api import sync_playwright
def main():
with sync_playwright() as p:
browser = p.chromium.launch(headless=False) # Set headless=True for running without a GUI
page = browser.new_page()
page.goto("https://example.com") # Replace with the URL you want to scroll through
# You may need to accept cookies or dismiss popups here
# Function to scroll down
def scroll_down(page, times, delay):
for _ in range(times):
page.mouse.wheel(0, 1000) # Scroll down
page.wait_for_timeout(delay) # Wait before scrolling again
# Adjust these parameters as needed
scroll_times = 10 # Number of times to scroll down
scroll_delay = 2000 # Delay between scrolls in milliseconds
scroll_down(page, scroll_times, scroll_delay)
# Optionally, take a screenshot after scrolling
page.screenshot(path="scrolled_page.png")
browser.close()
if __name__ == "__main__":
main()
Key Points:
- Install Playwright: Ensure you have Playwright installed. You can install it using
pip install playwright
and set up the necessary browsers usingplaywright install
. - Headless Mode: The
headless=False
option runs the browser in a visible mode. Change it toTrue
if you want to run it without a GUI. - Adjust Scroll Parameters: You can adjust the number of scrolls and the delay between them to suit your needs.
This script can be customized further based on the structure of the website you’re working with and the specific ads or elements you want to interact with.