|
@@ -132,12 +132,16 @@ async def get_domain_by_keyword(req:kw_req):
|
|
|
jsdict={'SiteName':js['name'],'Description':js['siteDescription'],'GlobalRank':js['globalRank'],'Title':js['name'],'Category':js['categoryRank']['taxonomy'],'CountryRank':js['countryRank']['rank']}
|
|
|
url = "https://similarweb2.p.rapidapi.com/trafficoverview"
|
|
|
querystring = {"website":domain_name}
|
|
|
-
|
|
|
- response = requests.request("GET", url, headers=headers, params=querystring)
|
|
|
- js2=json.loads(response.text)
|
|
|
- print(js2)
|
|
|
- jsdict['totalVisits'] = js2['engagement']['totalVisits']
|
|
|
- jsdict['EstimatedMonthlyVisits']=js2['monthlyVisitsEstimate']
|
|
|
+ try:
|
|
|
+ response = requests.request("GET", url, headers=headers, params=querystring)
|
|
|
+ js2=json.loads(response.text)
|
|
|
+ print(js2)
|
|
|
+ jsdict['totalVisits'] = js2['engagement']['totalVisits']
|
|
|
+ jsdict['EstimatedMonthlyVisits']=js2['monthlyVisitsEstimate']
|
|
|
+ except:
|
|
|
+ jsdict['totalVisits'] ='no data'
|
|
|
+ jsdict['EstimatedMonthlyVisits'] = 'no data'
|
|
|
+
|
|
|
log_table = db['storage_similar_web']
|
|
|
log_table.insert({'SiteName':raw_domain,'Description':jsdict['Description'],'GlobalRank':jsdict['GlobalRank']
|
|
|
,'Title':jsdict['Title'],'Category':jsdict['Category'],'CountryRank':jsdict['CountryRank'],'EstimatedMonthlyVisits':jsdict['EstimatedMonthlyVisits']
|