Google Autocomplete Suggestions in Python

Поделиться
HTML-код
  • Опубликовано: 29 апр 2024
  • Today we learn how to automatically request Google autocomplete suggestions in Python.
    ◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
    📚 Programming Books & Merch 📚
    🐍 The Python Bible Book: www.neuralnine.com/books/
    💻 The Algorithm Bible Book: www.neuralnine.com/books/
    👕 Programming Merch: www.neuralnine.com/shop
    💼 Services 💼
    💻 Freelancing & Tutoring: www.neuralnine.com/services
    🌐 Social Media & Contact 🌐
    📱 Website: www.neuralnine.com/
    📷 Instagram: / neuralnine
    🐦 Twitter: / neuralnine
    🤵 LinkedIn: / neuralnine
    📁 GitHub: github.com/NeuralNine
    🎙 Discord: / discord
  • НаукаНаука

Комментарии • 17

  • @jackmukendi3121
    @jackmukendi3121 Месяц назад +6

    Y’all wake up !!! NeuralNine just posted 🗣️ 🔥

  • @eklownr4566
    @eklownr4566 Месяц назад +10

    It looks like User-Agent is not being used

    • @birdie123
      @birdie123 Месяц назад

      The headers are not being utilized in the requests???

    • @rons96
      @rons96 Месяц назад

      No​@@birdie123

  • @TheMaxKids
    @TheMaxKids Месяц назад +2

    Always concise and to the point. I appreciate your videos very much.

  • @dipeshsamrawat7957
    @dipeshsamrawat7957 Месяц назад +1

    Thank you so much broh🤗

  • @omaral-halabiah2851
    @omaral-halabiah2851 Месяц назад

    good idea, thanks a lot

  • @throwyourmindat
    @throwyourmindat Месяц назад +1

    Hey @NeuralNine
    You havent used the header in the request.

  • @appearperson
    @appearperson Месяц назад

    instead of json.loads(response.text), you can do response.json()

  • @dipankarshaw900
    @dipankarshaw900 Месяц назад +2

    I have a doubt. What is the role of `headers` dictionary in this code ? He does not use that variable anywhere.

    • @bdcash
      @bdcash Месяц назад

      It tells request to pretend to be a browser with those stats. The server might block it if it isn't there. He forgot to use it, so it couldn't have mattered.

    • @allanbrand
      @allanbrand Месяц назад +1

      I ran the code without the headers line and it ran just fine. Also, in his example he listed the client as Chrome.

  • @elu1
    @elu1 Месяц назад

    that's nice. now can you get all the lists in one shot without going through a loop?

  • @tithos
    @tithos Месяц назад +1

    Proxy still woks!!

  • @Pyth_onist
    @Pyth_onist Месяц назад +1

    Hello fellow pythonist.

  • @emeraldrhyme5634
    @emeraldrhyme5634 Месяц назад +1

    would this not do the job aswell ?
    pip install googlesearch-python
    from googlesearch import autocomplete
    def get_autocomplete_suggestions(query):
    try:
    suggestions = autocomplete(query)
    return suggestions
    except Exception as e:
    print("An error occurred:", e)
    return None
    if __name__ == "__main__":
    search_query = input("Enter your search query: ")
    suggestions = get_autocomplete_suggestions(search_query)
    if suggestions:
    print("Autocomplete Suggestions:")
    for suggestion in suggestions:
    print("-", suggestion)
    else:
    print("No autocomplete suggestions found.")