Add1E commited on
Commit
fa60cb9
·
verified ·
1 Parent(s): 2dd9e21

Update trend_crawl2.py

Browse files
Files changed (1) hide show
  1. trend_crawl2.py +0 -28
trend_crawl2.py CHANGED
@@ -30,34 +30,6 @@ def click_and_scrape(driver, url):
30
  try:
31
  driver.get(url)
32
 
33
- for attempt in range(4):
34
- try:
35
- # Write the page source into an HTML file
36
- with open("output.html", "w", encoding="utf-8") as file:
37
- file.write(driver.page_source)
38
-
39
- print("Page source has been written to output.html.")
40
- button = WebDriverWait(driver, 20).until(
41
- EC.element_to_be_clickable((
42
- By.XPATH,
43
- "//button[@aria-label='Alle Kategorien, Kategorie auswählen']"
44
- ))
45
- )
46
- print("Button located.")
47
-
48
- # Scroll into view to ensure visibility
49
- driver.execute_script("arguments[0].scrollIntoView();", button)
50
- print(button.get_attribute("outerHTML"))
51
-
52
-
53
- button.click()
54
- print("Button clicked successfully.")
55
- break
56
- except ElementClickInterceptedException:
57
- print(f"Attempt {attempt + 1}: Click intercepted. Retrying...")
58
-
59
-
60
-
61
  # Wait for the ul element to load
62
  try:
63
  # Wait for the ul element with the specific aria-label to load
 
30
  try:
31
  driver.get(url)
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  # Wait for the ul element to load
34
  try:
35
  # Wait for the ul element with the specific aria-label to load