-
Notifications
You must be signed in to change notification settings - Fork 0
/
kod.py
52 lines (38 loc) · 1.26 KB
/
kod.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Haber Okuma Programı v1
# 26.10.2019 - github.com/zkcplk
from selenium import webdriver
import time
import random
print("-----", "Haber Okuma Programı v1", "-----")
liste = {}
driver = webdriver.Firefox()
def git():
global liste
if 0 not in liste.values():
driver.get('https://www.ensonhaber.com/son-dakika')
links = driver.find_elements_by_class_name('news-item')
for i in links:
temp = i.get_attribute('href')
if "videonuz.ensonhaber.com" not in temp:
if temp not in liste:
liste[temp] = 0
# print(liste)
temp_liste = [k for k,v in liste.items() if v == 0]
sec = random.choice(temp_liste)
print("Gidilen Sayfa >>> " + sec)
driver.get(sec)
liste[sec] = 1
time.sleep(1)
sayac = 200
lenOfPage = driver.execute_script(
"window.scrollTo(0, " + str(sayac) + ");var lenOfPage=document.body.scrollHeight-1111;return lenOfPage;")
match = False
while not match:
sayac += 101
time.sleep(0.777)
driver.execute_script("window.scrollTo(0, " + str(sayac) + ");return true;")
if sayac > lenOfPage:
match = True
time.sleep(1)
git()
git()