මේක හරිද කියලා කියන්නෝ

Boralugoda01

Well-known member
  • Apr 23, 2017
    3,378
    1
    3,143
    113
    නගරසභාවේ
    මෙන්න මේ code එක මම ආතල් එකට වගේ google bird ට කියලා ලියවාගත්තා.. Coding ගැන දන්න අය මේක පොඩ්ඩක් බලල හරිද කියන්න පුළුවන් ද..?

    import requests

    from bs4 import BeautifulSoup



    # Get the top search keywords from Google Trends

    url = "https://trends.google.com/trends/explore?date=all&q=keyword1,keyword2,keyword3"

    response = requests.get(url)

    soup = BeautifulSoup(response.content, "html.parser")



    # Extract the keywords and their search volumes

    keywords = []

    for trend in soup.find_all("div", class_="trend-title"):

    keyword = trend.find("a").text

    search_volume = trend.find("span", class_="value").text

    keywords.append((keyword, search_volume))



    # Filter the keywords by search volume

    min_search_volume = 1000

    keywords = [keyword for keyword, search_volume in keywords if int(search_volume) >= min_search_volume]



    # Get the keyword difficulty for each keyword

    keyword_difficulty = {}

    for keyword in keywords:

    url = "https://ahrefs.com/keyword-difficulty/{}?hflag=1".format(keyword)

    response = requests.get(url)

    soup = BeautifulSoup(response.content, "html.parser")



    # Extract the keyword difficulty

    keyword_difficulty[keyword] = soup.find("span", class_="keyword-difficulty").text



    # Sort the keywords by keyword difficulty

    sorted_keywords = sorted(keyword_difficulty.items(), key=lambda x: x[1])



    # Print the top 10 low-competition keywords

    for keyword, difficulty in sorted_keywords[:10]:

    print("{} ({})".format(keyword, difficulty))
     
    • Like
    Reactions: NRTG and Solo Rider

    EdNygma

    Well-known member
  • Nov 20, 2016
    5,613
    13,473
    113
    බැලූ බැල්මෙන් code එකේ නම් අවුලක් නෑ වගේ හැබැයි ඕක run කරාම මගින් නතර වෙයි. Google Trends එකයි Ahrefs එකයි scrape කරන්න නේ යන්නේ..

    සමහර වෙලාවට ඒ වගේ site වලින් automated task එකක් කියලා දැක්කා ගමන් captcha page එකකට වගේ යවලා block කරනවා.
     

    hasithayad

    Well-known member
  • Sep 28, 2011
    30,793
    1
    45,000
    113
    මෙන්න මේ code එක මම ආතල් එකට වගේ google bird ට කියලා ලියවාගත්තා.. Coding ගැන දන්න අය මේක පොඩ්ඩක් බලල හරිද කියන්න පුළුවන් ද..?
    මේක වැඩ නෑ නේද

    https://ahrefs.com/keyword-difficulty/{keywords}?hflag=1

    ඒක වැඩ නෑ කියන්නෙ කෝඩ් එකම වැඩ නෑ