selenium instagram oto post beğeni için yardım

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Onaylı Üye
Katılım
21 Kas 2020
Mesajlar
145
Çözümler
3
Tepki puanı
18
Ödüller
4
Yaş
23
5 HİZMET YILI
python selenium kullanarak instagramda bir sayfaya girip tüm postlarını sırayla beğenen bir kod yazmaya çalışıyorum instagram apı olsa çok daha iyi olurdu ama instagra apı verebilecek ve ya nasıl alabileceğimi anlatabilecek varsa çok memnun olurum neyse


from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By

driver.get('
Bağlantıları görmek için lütfen Giriş Yap
') #Go to instagram login page.
sleep(3) #Wait for loading page.
username_input = driver.find_element(By.NAME, 'username')
username_input.send_keys('senin k.adın')
password_input = driver.find_element(By.NAME, 'password')
password_input.send_keys('senin şifren')
sleep(2)
login_button = driver.find_element(By.XPATH, '//button[@type="submit"]')
login_button.click()
sleep(5)
# Profil sayfasına gidin
driver.get('
Bağlantıları görmek için lütfen Giriş Yap
sayfa/?hl=tr')
# Sayfayı yükleyin ve biraz bekleyin
sleep(10)
def scrollAllWayDown():
#This function scroll down to see the footer element and wait for a couple second. If page scroll length has changed then scroll again because that mean there is other pictures.
global driver
footer = driver.find_element_by_tag_name('footer') #The footer element
last_height = driver.execute_script('return document.body.scrollHeight') #Before scroll down note scroll length
while True:
footer.location_once_scrolled_into_view #Scroll down to see footer
sleep(2) #Wait for internet
new_height = driver.execute_script('return document.body.scrollHeight') #Run javascript code again to check scroll length.
if new_height == last_height: #If scroll height hasnt changed then there is no more pictures.
print('sayfa bitti!!!')
break
else: #If it changed set the last height equal new height and repeat function.
last_height = new_height
scrollAllWayDown()
tumKutular = driver.find_elements_by_class_name('v1Nh3') #Every photo attribute has a parent div so first find divs
tumLinkler = []
for i in tumKutular:
tumLinkler.append(i.find_element_by_tag_name('a')) #And find attribute in divs
for i in tumLinkler:
i.click() #Click link and open photo
sleep(2)
begenbuton = driver.find_element_by_xpath('/html/body/div[4]/div[2]/div/article/div[3]/section[1]/span[1]/button')
begenbuton.click() #Click heart button
sleep(0.2)
cikis = driver.find_element_by_xpath('/html/body/div[4]/div[3]/button').click() #Click exit button

kaynak kodlarını başka yerlerden aldım hepsi bana ait değil yardımcı olabilecek varsa çok iyi olur aldığım çıktı:
DevTools listening on ws://127.0.0.1:60004/devtools/browser/35aa8b7c-a1fa-4061-8ab4-1f2123283355
[9524:8612:1230/153635.776:ERROR:device_event_log_impl.cc(215)] [15:36:35.779] Bluetooth: bluetooth_adapter_winrt.cc:1074 Getting Default Adapter failed.
Traceback (most recent call last):
File "c:\Users\mansi\OneDrive\Masaüstü\python_temelleri\denelütfen.py", line 38, in <module>
scrollAllWayDown()
File "c:\Users\mansi\OneDrive\Masaüstü\python_temelleri\denelütfen.py", line 26, in scrollAllWayDown
footer = driver.find_element_by_tag_name('footer') #The footer element
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'WebDriver' object has no attribute 'find_element_by_tag_name'
 
Moderatörün son düzenlenenleri:
Onaylı Üye
Katılım
30 Ocak 2022
Mesajlar
58
Tepki puanı
3
Ödüller
2
Yaş
26
4 HİZMET YILI
Hocam insta tagı - linki girmemişsiniz lütfen girin ve türkçe karakter kullanmamayaa özen gösterin yazarken
 
Ne Mutlu Türküm Diyene
Seçkin Üye
Katılım
18 Şub 2016
Mesajlar
306
Tepki puanı
33
Ödüller
9
10 HİZMET YILI
python selenium kullanarak instagramda bir sayfaya girip tüm postlarını sırayla beğenen bir kod yazmaya çalışıyorum instagram apı olsa çok daha iyi olurdu ama instagra apı verebilecek ve ya nasıl alabileceğimi anlatabilecek varsa çok memnun olurum neyse


from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By

driver.get('
Bağlantıları görmek için lütfen Giriş Yap
') #Go to instagram login page.
sleep(3) #Wait for loading page.
username_input = driver.find_element(By.NAME, 'username')
username_input.send_keys('senin k.adın')
password_input = driver.find_element(By.NAME, 'password')
password_input.send_keys('senin şifren')
sleep(2)
login_button = driver.find_element(By.XPATH, '//button[@type="submit"]')
login_button.click()
sleep(5)
# Profil sayfasına gidin
driver.get('
Bağlantıları görmek için lütfen Giriş Yap
sayfa/?hl=tr')
# Sayfayı yükleyin ve biraz bekleyin
sleep(10)
def scrollAllWayDown():
#This function scroll down to see the footer element and wait for a couple second. If page scroll length has changed then scroll again because that mean there is other pictures.
global driver
footer = driver.find_element_by_tag_name('footer') #The footer element
last_height = driver.execute_script('return document.body.scrollHeight') #Before scroll down note scroll length
while True:
footer.location_once_scrolled_into_view #Scroll down to see footer
sleep(2) #Wait for internet
new_height = driver.execute_script('return document.body.scrollHeight') #Run javascript code again to check scroll length.
if new_height == last_height: #If scroll height hasnt changed then there is no more pictures.
print('sayfa bitti!!!')
break
else: #If it changed set the last height equal new height and repeat function.
last_height = new_height
scrollAllWayDown()
tumKutular = driver.find_elements_by_class_name('v1Nh3') #Every photo attribute has a parent div so first find divs
tumLinkler = []
for i in tumKutular:
tumLinkler.append(i.find_element_by_tag_name('a')) #And find attribute in divs
for i in tumLinkler:
i.click() #Click link and open photo
sleep(2)
begenbuton = driver.find_element_by_xpath('/html/body/div[4]/div[2]/div/article/div[3]/section[1]/span[1]/button')
begenbuton.click() #Click heart button
sleep(0.2)
cikis = driver.find_element_by_xpath('/html/body/div[4]/div[3]/button').click() #Click exit button

kaynak kodlarını başka yerlerden aldım hepsi bana ait değil yardımcı olabilecek varsa çok iyi olur aldığım çıktı:
DevTools listening on ws://127.0.0.1:60004/devtools/browser/35aa8b7c-a1fa-4061-8ab4-1f2123283355
[9524:8612:1230/153635.776:ERROR:device_event_log_impl.cc(215)] [15:36:35.779] Bluetooth: bluetooth_adapter_winrt.cc:1074 Getting Default Adapter failed.
Traceback (most recent call last):
File "c:\Users\mansi\OneDrive\Masaüstü\python_temelleri\denelütfen.py", line 38, in <module>
scrollAllWayDown()
File "c:\Users\mansi\OneDrive\Masaüstü\python_temelleri\denelütfen.py", line 26, in scrollAllWayDown
footer = driver.find_element_by_tag_name('footer') #The footer element
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'WebDriver' object has no attribute 'find_element_by_tag_name'
hocam tag name de problem var py bilgim yok java olsaydı deneyip hatanın tam olarak neyden kaynaklandığı söylerdim py ve java da selenium syntax farklı hiç py bilmediğim için tam hata ne anlayamadım
 
Son düzenleme:
Onaylı Üye
Katılım
21 Kas 2020
Mesajlar
145
Çözümler
3
Tepki puanı
18
Ödüller
4
Yaş
23
5 HİZMET YILI
python selenium kullanarak instagramda bir sayfaya girip tüm postlarını sırayla beğenen bir kod yazmaya çalışıyorum instagram apı olsa çok daha iyi olurdu ama instagra apı verebilecek ve ya nasıl alabileceğimi anlatabilecek varsa çok memnun olurum neyse


from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By

driver.get('
Bağlantıları görmek için lütfen Giriş Yap
') #Go to instagram login page.
sleep(3) #Wait for loading page.
username_input = driver.find_element(By.NAME, 'username')
username_input.send_keys('senin k.adın')
password_input = driver.find_element(By.NAME, 'password')
password_input.send_keys('senin şifren')
sleep(2)
login_button = driver.find_element(By.XPATH, '//button[@type="submit"]')
login_button.click()
sleep(5)
# Profil sayfasına gidin
driver.get('
Bağlantıları görmek için lütfen Giriş Yap
sayfa/?hl=tr')
# Sayfayı yükleyin ve biraz bekleyin
sleep(10)
def scrollAllWayDown():
#This function scroll down to see the footer element and wait for a couple second. If page scroll length has changed then scroll again because that mean there is other pictures.
global driver
footer = driver.find_element_by_tag_name('footer') #The footer element
last_height = driver.execute_script('return document.body.scrollHeight') #Before scroll down note scroll length
while True:
footer.location_once_scrolled_into_view #Scroll down to see footer
sleep(2) #Wait for internet
new_height = driver.execute_script('return document.body.scrollHeight') #Run javascript code again to check scroll length.
if new_height == last_height: #If scroll height hasnt changed then there is no more pictures.
print('sayfa bitti!!!')
break
else: #If it changed set the last height equal new height and repeat function.
last_height = new_height
scrollAllWayDown()
tumKutular = driver.find_elements_by_class_name('v1Nh3') #Every photo attribute has a parent div so first find divs
tumLinkler = []
for i in tumKutular:
tumLinkler.append(i.find_element_by_tag_name('a')) #And find attribute in divs
for i in tumLinkler:
i.click() #Click link and open photo
sleep(2)
begenbuton = driver.find_element_by_xpath('/html/body/div[4]/div[2]/div/article/div[3]/section[1]/span[1]/button')
begenbuton.click() #Click heart button
sleep(0.2)
cikis = driver.find_element_by_xpath('/html/body/div[4]/div[3]/button').click() #Click exit button

kaynak kodlarını başka yerlerden aldım hepsi bana ait değil yardımcı olabilecek varsa çok iyi olur aldığım çıktı:
DevTools listening on ws://127.0.0.1:60004/devtools/browser/35aa8b7c-a1fa-4061-8ab4-1f2123283355
[9524:8612:1230/153635.776:ERROR:device_event_log_impl.cc(215)] [15:36:35.779] Bluetooth: bluetooth_adapter_winrt.cc:1074 Getting Default Adapter failed.
Traceback (most recent call last):
File "c:\Users\mansi\OneDrive\Masaüstü\python_temelleri\denelütfen.py", line 38, in <module>
scrollAllWayDown()
File "c:\Users\mansi\OneDrive\Masaüstü\python_temelleri\denelütfen.py", line 26, in scrollAllWayDown
footer = driver.find_element_by_tag_name('footer') #The footer element
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'WebDriver' object has no attribute 'find_element_by_tag_name'
direkt kodu değiştirdim başaramadım boyumdan büyük işlere kalkışmışım yardım etmeye çalıştığınız için teşekkür ederim eğer instagram bir sayfadaki tüm postları beğenme botu yazabilirseniz dm den dönüş yapabilirseniz sevinirim iyi forumlar
 
Seçkin Üye
Katılım
12 Kas 2017
Mesajlar
320
Tepki puanı
14
Ödüller
8
Yaş
31
8 HİZMET YILI
Türkçe karakter kullandıysan ondan olabilir türkçe karakter kullanmamaya dikkat etmeni öneriyorum
 
Onaylı Üye
Katılım
13 Mar 2023
Mesajlar
50
Tepki puanı
4
Ödüller
1
Yaş
36
3 HİZMET YILI
find_element_by_tag_name kısmında sıkıntı çıkmış. driver.find_element(By.ID, 'footer') yazarsan düzelebilir. Taglarin doğru olduğundan emin ol
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst