sahanind commited on
Commit
5370707
·
verified ·
1 Parent(s): ce1f885

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -7
app.py CHANGED
@@ -20,14 +20,49 @@ driver.get(url)
20
  # Print the page title to verify success
21
  print(driver.title)
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  # Use WebDriverWait to wait for the element to be present
24
- try:
25
- my_tab_content = WebDriverWait(driver, 10).until(
26
- EC.presence_of_element_located((By.ID, "myTabContent"))
27
- )
28
- print(my_tab_content.text) # Print the text content
29
- except Exception as e:
30
- print("Error locating the element:", e)
31
 
32
  # Close the browser session
33
  driver.quit()
 
20
  # Print the page title to verify success
21
  print(driver.title)
22
 
23
+
24
+ jsc = """
25
+ function find360pLink() {
26
+ // Select all table rows
27
+ const rows = document.querySelectorAll('tr');
28
+ let link = '';
29
+
30
+ // Loop through each row to find the one containing "360p"
31
+ rows.forEach(row => {
32
+ const cells = row.getElementsByTagName('td');
33
+ if (cells.length > 0 && cells[0].textContent.includes("360p")) {
34
+ // Find the anchor element within this row
35
+ const anchor = row.querySelector('a');
36
+ if (anchor) {
37
+ link = anchor.getAttribute('href'); // Get the href attribute
38
+ }
39
+ }
40
+ });
41
+
42
+ // Print the link
43
+ if (link) {
44
+ console.log('360p Link:', link);
45
+ return link
46
+ } else {
47
+ console.log('360p link not found.');
48
+ }
49
+ }
50
+
51
+ // Call the function to find the 360p link
52
+ find360pLink();
53
+ """
54
+
55
+ dls = driver.execute_script(jsc)
56
+
57
+ print(dls)
58
  # Use WebDriverWait to wait for the element to be present
59
+ #try:
60
+ # my_tab_content = WebDriverWait(driver, 10).until(
61
+ # EC.presence_of_element_located((By.ID, "myTabContent"))
62
+ # )
63
+ # print(my_tab_content.text) # Print the text content
64
+ #except Exception as e:
65
+ # print("Error locating the element:", e)
66
 
67
  # Close the browser session
68
  driver.quit()