Aug 23, 2017 · 1 min read
Hi , to get some persons or companies social media URLs
we can do in two ways
1)scrape their portfolio website or company home page after scarping get that results in an array and search for facebook.com, if find out that result
2) using Microsoft congnitive services Python API
https://www.microsoft.com/cognitive-services
subscribe to Bing Search -Free and get the subscription key
Later, in your python IDE use the fallowing test code with python 2.x code
I am searching Kim kardashian facebook linksand gonna print them
import httplib, urllib, base64
headers = {
# Request headers
'Ocp-Apim-Subscription-Key': 'XXXXXXXXXXXX197245axxxxxx41e'
}
params = urllib.urlencode({
# Request parameters
'q': 'kim kardashian facebook',
'count': '10', # no.of results you want
'offset': '0', # no.of results you need to skip before printing out
'mkt': 'en-us', # which country results you wanna search,
# sometimes u wanna search bing UK or bing India or bing Aus
'safesearch': 'Moderate',
})
try:
conn = httplib.HTTPSConnection('api.cognitive.microsoft.com')
conn.request("GET", "/bing/v5.0/search?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
#here comes our code
#output data is in string format, split it using white spaces
#and make it into array
#then loop the array
datax=data.split(" ")
for xy in datax:
#if the array element conatians facebook.com and not bing
if "facebook.com" in xy and "bing" not in xy:
#then print it to '\/' with '/'
print xy.replace("\/","/")
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))