सरल पायथन स्क्रिप्ट जो Google कस्टम सर्च JSON API का उपयोग करके सर्च इंजन परिणामों में किसी कीवर्ड की स्थिति की जाँच करती है। आपको API के लिए साइन अप करना होगा और API कुंजी प्राप्त करनी होगी। इसके अतिरिक्त, आपको एक कस्टम सर्च इंजन बनाना होगा और उसकी ID प्राप्त करनी होगी।

import requests

def get_search_results(keyword, api_key, cx):
    url = f"https://www.googleapis.com/customsearch/v1?key={api_key}&cx={cx}&q={keyword}"
    response = requests.get(url)
    if response.status_code == 200:
        data = response.json()
        return data.get('items', [])
    else:
        print("Error occurred:", response.status_code)
        return []

def find_keyword_position(search_results, keyword):
    for index, result in enumerate(search_results, start=1):
        if keyword.lower() in result['title'].lower() or keyword.lower() in result['snippet'].lower():
            return index
    return -1

def check_keyword_position(keyword, api_key, cx):
    search_results = get_search_results(keyword, api_key, cx)
    if search_results:
        position = find_keyword_position(search_results, keyword)
        if position != -1:
            print(f"The keyword '{keyword}' is found at position {position} in search results.")
        else:
            print(f"The keyword '{keyword}' is not found in the first 10 search results.")
    else:
        print("No search results found.")

if __name__ == "__main__":
    keyword = input("Enter the keyword to check position for: ")
    api_key = input("Enter your Google API key: ")
    cx = input("Enter your Custom Search Engine ID: ")
    check_keyword_position(keyword, api_key, cx)

प्रतिस्थापित करना सुनिश्चित करें "YOUR_API_KEY" अपनी वास्तविक Google API कुंजी के साथ और "YOUR_CUSTOM_SEARCH_ENGINE_ID" अपने कस्टम खोज इंजन आईडी के साथ.

इस स्क्रिप्ट का उपयोग करने के लिए, बस इसे अपने पायथन वातावरण में चलाएँ, और यह आपको वह कीवर्ड दर्ज करने के लिए प्रेरित करेगा जिसकी स्थिति आप जाँचना चाहते हैं, आपकी Google API कुंजी, और आपका कस्टम सर्च इंजन आईडी। फिर यह खोज परिणामों में कीवर्ड की स्थिति प्रदर्शित करेगा, यदि वह पाया जाता है।

टिप्पणियाँ (0)

यहां अभी तक कोई टिप्पणी नहीं है, आप पहले हो सकते हैं!

प्रातिक्रिया दे

आपका ईमेल पता प्रकाशित नहीं किया जाएगा. आवश्यक फ़ील्ड चिह्नित हैं *


प्रॉक्सी चुनें और खरीदें

डेटासेंटर प्रॉक्सी

घूर्णनशील प्रॉक्सी

यूडीपी प्रॉक्सी

दुनिया भर में 10000 से अधिक ग्राहकों द्वारा विश्वसनीय

प्रॉक्सी ग्राहक
प्रॉक्सी ग्राहक
प्रॉक्सी ग्राहक प्रवाहch.ai
प्रॉक्सी ग्राहक
प्रॉक्सी ग्राहक
प्रॉक्सी ग्राहक