Skip to content

Instantly share code, notes, and snippets.

View thilohuellmann's full-sized avatar
👀
curious

Thilo Huellmann thilohuellmann

👀
curious
View GitHub Profile
import http.client, urllib.request, urllib.parse, urllib.error, base64
import json
import csv
names = ['YOUR LIST OF NAMES']
companies = ['YOUR LIST OF COMPANIES FOR EACH NAME']
YOUR_API_KEY = 'YOUR_API_KEY'
linkedin = []
# Writing the results to a CSV file
with open('linkedin.csv', 'w', newline='', encoding='utf-8') as f:
writer = csv.writer(f)
for row in linkedin:
writer.writerow(row)
print('Number of LinkedIn profiles found:')
print(len(linkedin))
for result in json_file['webPages']['value']:
title = result['name']
if name.lower() in title.lower(): # checks if the name appears in the title
if 'linkedin.com/in/' in result['displayUrl']: # checks if the search result URL is a LI profile
linkedin.append([name, company, result['displayUrl']])
break
for name, company in zip(names, companies): # zip to loop over names and companies simultaneously
query = name + company
headers = {'Ocp-Apim-Subscription-Key': YOUR_API_KEY }
params = urllib.parse.urlencode({'q': query,'count': '2','mkt': 'de-DE'}) # returns top 2 (German) results
conn = http.client.HTTPSConnection('api.cognitive.microsoft.com')
conn.request("GET", "/bing/v5.0/search?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read().decode('utf-8')

100 Days Of ML Code - Example Log

Use this as a base template. Create your own repository on GitHub and start logging your work daily!

Day 0: February 29, 2016 (Example 1)

(delete me or comment me out)

Today's Progress: Fixed CSS, worked on canvas functionality for the app.

Thoughts: I really struggled with CSS, but, overall, I feel like I am slowly getting better at it. Canvas is still new for me, but I managed to figure out some basic functionality.

with open('transformed_addresses.csv', 'w', newline='', encoding='utf-8') as f:
writer = csv.writer(f)
for row in transformed:
writer.writerow(row)
for query in tqdm(addresses):
# API call, storing information as JSON
url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' + query + '&lang=en&key=' + api_key
r = requests.get(url)
data = r.json()
{
"results" : [
{
"address_components" : [
{
"long_name" : "221B",
"short_name" : "221B",
"types" : [ "street_number" ]
},
{
@thilohuellmann
thilohuellmann / main.py
Last active May 17, 2019 12:40
medium4
for query in tqdm(addresses):
# API call, storing information as JSON
url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' + query + '&lang=en&key=' + api_key
r = requests.get(url)
data = r.json()
# clear all values to avoid appending values from previous iterations a second time
number = street = country = postal_code = city = ''
# Get addresses from CSV
addresses = addresses_from_csv(path='path/to/your/file.csv', column=0)
# Set Google Maps API key
api_key = YOUR_API_KEY
# Initialize array for transformed addresses
transformed = []
transformed.append(['Country', 'Post code', 'City', 'Street & No'])