Free keyword tool generator
from flask import Flask, request, jsonify, render_template
from googleapiclient.discovery import build
app = Flask(__name__)
# Replace this with your provided API key
API_KEY = "AIzaSyBP06MiM2onAlfi6ozhnBkQuDDf5NBuI1g"
@app.route('/')
def home():
return render_template('index.html')
@app.route('/keyword-research', methods=['GET'])
def keyword_research():
keyword = request.args.get('keyword')
if not keyword:
return jsonify({"error": "Keyword parameter is required."}), 400
try:
# Initialize the API service
service = build('customsearch', 'v1', developerKey=API_KEY)
# Perform a search query to simulate keyword data retrieval (customizable)
result = service.cse().list(
q=keyword,
cx="your_custom_search_engine_id" # Replace with your custom search engine ID
).execute()
# Simulate keyword data (replace this with actual data fetching logic)
data = {
"keyword": keyword,
"cpc": "$1.20", # Placeholder
"volume": "10,000", # Placeholder
"seo_difficulty": "35" # Placeholder
}
return jsonify(data)
except Exception as e:
return jsonify({"error": str(e)}), 500
if __name__ == '__main__':
app.run(debug=True)
Comments
Post a Comment