Python Selenium Tutorial: Scraping Google Search Results

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024

ความคิดเห็น • 27

  • @juandasisnawan9974
    @juandasisnawan9974 3 ปีที่แล้ว +1

    Hi, thank you for sharing this. But how do you scrape the data beyond the first page? and also prevent google from blocking us with captcha?

    • @ScrapingNinja
      @ScrapingNinja  3 ปีที่แล้ว

      Thanks for watching, new video about captcha and proxies is coming soon.. Don’t forget to subscribe

    • @juandasisnawan9974
      @juandasisnawan9974 3 ปีที่แล้ว

      @@ScrapingNinja Okay, thanks. I will wait for that, I am having a problem scraping the data reliably, because of the captcha.

  • @akshaymbhat9144
    @akshaymbhat9144 2 ปีที่แล้ว

    How to get search results if it contains more than 1 page like for example 100 pages. Please reply. Thanks

    • @ScrapingNinja
      @ScrapingNinja  2 ปีที่แล้ว

      Watch this video(link below), it explains about navigating through pages
      Web Scraping Google Search Results Using Selenium Python
      th-cam.com/video/8NXbUipUt8U/w-d-xo.html

  • @Programlama101
    @Programlama101 3 ปีที่แล้ว

    Hi, I also have videos about this topic but I did not use python more than a year so I forget selenium totally. I found your video and tried your codes but unfortunately the link part raises error and I couldn't solve it. Code is
    link = elem.find_element_by_xpath('.//div[@class="yuRUbf"]/a').get_attribute("href"))
    error is:
    selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":".//div[@class="yuRUbf"]/a"}
    It says no such element but I can find that element when I check from chrome. Do you have any idea?

    • @Programlama101
      @Programlama101 3 ปีที่แล้ว

      By the way I tried your code. It does not raise any error but it does not writes titles,links or descriptions to excel file.
      I try to see what it finds with print(title,link,detail) but it does not show anything.

    • @ScrapingNinja
      @ScrapingNinja  3 ปีที่แล้ว +1

      Hi Hasan Onur Atac thanks for reaching out, while scraping google search results note that google search results html structure is displayed differently for different languages and regions or when you browse in your browser and the chromedriver session structure could also be different. So there are two things to consider
      1. Inspect elements of chrome window that opens for script session or custom in terminal to navigate
      2. Test these and #comment title and detail for testing (I have tested this and working)
      for element in driver.find_elements_by_xpath('//div[@id="search"]//div[@class="g"]'):
      link = element.find_element_by_xpath('.//div[@class="yuRUbf"]/a').get_attribute('href')
      here is recently uploaded video for google search results scraping
      th-cam.com/video/8NXbUipUt8U/w-d-xo.html

    • @Programlama101
      @Programlama101 3 ปีที่แล้ว

      @@ScrapingNinja Hey this code works! thank you. I dont know how to detect proper way. I think it worked because of for element in driver.find_elements_by_xpath('//div[@id="search"]//div[@class="g"]'):
      this part. I will watch your new video right now. I hope you explain well how to find proper way for all situations.

    • @ScrapingNinja
      @ScrapingNinja  3 ปีที่แล้ว +1

      @@Programlama101 i am glad that it works for you...

  • @MuhammadAhmad-bx2rw
    @MuhammadAhmad-bx2rw 3 ปีที่แล้ว +1

    From where you learn web scrapping

    • @ScrapingNinja
      @ScrapingNinja  3 ปีที่แล้ว +2

      I am self taught from mostly stack overflow and github...

  • @meeransama3423
    @meeransama3423 ปีที่แล้ว

    Which python version do you use ?

    • @ScrapingNinja
      @ScrapingNinja  ปีที่แล้ว

      Its python 3.8 i am using in this video..

  • @hatfgamingyt271
    @hatfgamingyt271 3 ปีที่แล้ว +1

    Good job cahchu jan❤️

  • @ANURAGSHARMA091716
    @ANURAGSHARMA091716 3 ปีที่แล้ว

    Do you have this code on the Github repo? I need urgently for a job assignment!

    • @ScrapingNinja
      @ScrapingNinja  3 ปีที่แล้ว +1

      Yes it is available on github, i have added the link in video description

    • @ANURAGSHARMA091716
      @ANURAGSHARMA091716 3 ปีที่แล้ว +1

      @@ScrapingNinja Thank you!

  • @munirahmad2808
    @munirahmad2808 3 ปีที่แล้ว

    👍

  • @AlisTDK
    @AlisTDK 3 ปีที่แล้ว

    Ali

    • @ScrapingNinja
      @ScrapingNinja  3 ปีที่แล้ว

      Hi Thanks for taking the time to comment.

  • @jinaykothari4511
    @jinaykothari4511 2 ปีที่แล้ว

    This is all what i wanted
    Thanks @Let’sScrapeTheWeb creator
    Only one question drive.find_element_by_xpath is not working for me though i got the solution on StackOverflow but why i am getting this error

    • @ScrapingNinja
      @ScrapingNinja  2 ปีที่แล้ว

      I see typo here it should be driver.find_element_by_xpath

    • @jinaykothari4511
      @jinaykothari4511 2 ปีที่แล้ว

      @@ScrapingNinja yes

    • @jinaykothari4511
      @jinaykothari4511 2 ปีที่แล้ว

      @@ScrapingNinja and sir i am also not able to get the links of the particular div class see here’s my code
      link = driver.find_element(by = By.XPATH,value='.//div[@class="kno-rdesc"]/a').get_attribute('href')

    • @ScrapingNinja
      @ScrapingNinja  11 หลายเดือนก่อน

      Try to print(link) and then do link.get_attribute(‘href’)