add googleMaps scraping and openAI playground project
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
angebote_traegerMail_iteration/dict_*.json
|
||||
openAI_validate_data/2024-12 gpt-4o-mini/*.csv
|
||||
|
@@ -8,3 +8,11 @@ The Python3 script generates two JSON files from that. One holds the relation `{
|
||||
This input can be used to generate mails for the "opt-out method" (people can delete their offer from the MUT-ATLAS).
|
||||
### Output
|
||||
tbd
|
||||
|
||||
## openAI_validate_data
|
||||
### Processing
|
||||
These scripts aim to see what ChatGPT can do to validate your offers (Angebote).
|
||||
|
||||
## scrape_GoogleMaps
|
||||
### Processing
|
||||
Scenario: 'find offers (Angebote) with "Psychotherpeut" in a radius of 1000m around these coordinates..'
|
28
openAI_validate_data/2024-12 gpt-4o-mini/request.py
Normal file
28
openAI_validate_data/2024-12 gpt-4o-mini/request.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from openai import OpenAI
|
||||
client = OpenAI()
|
||||
|
||||
completion = client.chat.completions.create(
|
||||
model="gpt-4o-mini",
|
||||
messages=[
|
||||
{"role": "system", "content": "You are a helpful assistant."},
|
||||
{
|
||||
"role": "user",
|
||||
"content": """Ich hab hier 5 unvalidierte Daten zu psychologischen Einrichtungen oder Angeboten, die ich gerne validiert und ggf. korrigiert hätte. Folgende Probleme hab ich mit den Daten:
|
||||
Einige "Angebote" sind eher Träger und kein Angebot. Bitte recherchiere das eigentliche Angebot, die korrekten Adresse zu ebenselbigem und gib eine spezifische URL zum Angebot mit, gerne im Feld "Homepage".
|
||||
Das Ergebnis kannst du gerne als CSV (wie den Input) zurückgeben. Hier die Daten:
|
||||
|
||||
Name,Firma,Straße,StraßeNrEingabe,StraßeEingabe,PLZ,Ort,Bundesland,DRV Gebiet,Landkreis,Telefon,Themen,Telefon mobil,Email,HomePage,URL_AngebotKurz,Themen
|
||||
Regionaldienste des Jugendamtes Lichtenberg,Bezirksamt Lichtenberg,Große Leege-Straße 103,103,Große Leege-Straße,13055,Berlin,Berlin,Berlin-Brandenburg,,030 90296-7031,,030 90296-7031,juginfo@lichtenberg.berlin.de,,http://www.berlin.de,
|
||||
Allgemeiner Sozialer Dienst (ASD) Jugendamt Rhein-Pfalz-Kreis Lageplan,Rhein-Pfalz-Kreis,Europaplatz 5,5,Europaplatz,67063,Ludwigshafen,Rheinland-Pfalz,Rheinland-Pfalz,,0621 5909-1400,,0621 5909-1400,silvia.burre@rheinpfalzkreis.de,,http://www.rhein-pfalz-kreis.de,
|
||||
Drogenhilfe Stadt Ludwigshafen Lageplan,Stadt Ludwigshafen am Rhein,Goethestraße 12,12,Goethestraße,67063,Ludwigshafen,Rheinland-Pfalz,Rheinland-Pfalz,,0621 504-2870,,0621 504-2870,drogenhilfe@ludwigshafen.de,,http://www.ludwigshafen.de,
|
||||
Plan B gGmbH Jugend-und Drogenberatungsstelle,Plan B gGmbH,Schießhausstraße 6,6,Schießhausstraße,75173,Pforzheim,Baden-Württemberg,Baden-Württemberg,,07231 92277-0,,07231 92277-0,beratung@planb-pf.de,,http://www.planb-pf.de,
|
||||
Queer Space Pforzheim Beratung von LSBTTIQA-Menschen,AIDS-Hilfe Pforzheim e.V.,Goldschmiedeschulstraße 6,6,Goldschmiedeschulstraße,75173,Pforzheim,Baden-Württemberg,Baden-Württemberg,,07231 44 1110,,07231 44 1110,queerspace@ah-pforzheim.de,,http://www.ah-pforzheim.de/queer-space/,
|
||||
"""
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
response = completion.choices[0].message
|
||||
|
||||
print("Response: \n'"+ response.content + "'")
|
||||
print("\n\nFull response: ", response)
|
35
openAI_validate_data/2025-07/request.py
Normal file
35
openAI_validate_data/2025-07/request.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from openai import OpenAI
|
||||
from copy import deepcopy
|
||||
client = OpenAI()
|
||||
|
||||
startQuestion = """Ich hab hier unvalidierte Daten zu psychologischen Einrichtungen oder Angeboten, die ich gerne validiert und ggf. korrigiert hätte.
|
||||
Checke bitte, ob die Angebote die korrekte Adresse und Webseite haben. Ggf kannst du ja noch passende Themen in Kürze auflisten.
|
||||
Sag mir, was du an den Daten ändern würdest. Halte dich kurz.
|
||||
|
||||
Name,Firma,Straße,StraßeNrEingabe,StraßeEingabe,PLZ,Ort,Bundesland,DRV Gebiet,Landkreis,Telefon,Themen,Telefon mobil,Email,HomePage,Themen
|
||||
Regionaldienste des Jugendamtes Lichtenberg,Bezirksamt Lichtenberg,Große Leege-Straße 103,103,Große Leege-Straße,13055,Berlin,Berlin,Berlin-Brandenburg,,030 90296-7031,,030 90296-7031,juginfo@lichtenberg.berlin.de,,http://www.berlin.de,
|
||||
"""
|
||||
choice = "start"
|
||||
|
||||
while (choice != ""):
|
||||
choice2 = input("Press 'Enter' to call ChatGPT now.. ")
|
||||
if (choice2 == ""):
|
||||
completion = client.chat.completions.create(
|
||||
model="gpt-4o-mini",
|
||||
messages=[
|
||||
{"role": "system", "content": "You are a helpful assistant."},
|
||||
{
|
||||
"role": "user",
|
||||
"content": startQuestion if choice == "start" else choice
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
response = completion.choices[0].message
|
||||
|
||||
print("Response: \n'"+ response.content + "'")
|
||||
del response.content
|
||||
|
||||
print("\nEnveloped response content: ", response)
|
||||
choice = input("Ask something or leave blank to exit.. ").strip()
|
||||
print("Ok ciao")
|
21
scrape_GoogleMaps/places.csv
Normal file
21
scrape_GoogleMaps/places.csv
Normal file
@@ -0,0 +1,21 @@
|
||||
Name,Adresse,Bewertung,Anzahl Bewertungen,Typ
|
||||
Frau Dr. med. Susanne Schmitz,"Kölner Str. 79, Leverkusen",4.6,10,"doctor, health, point_of_interest, establishment"
|
||||
Dipl. Psych. Erika Toussaint (geb. Benz),"Uhlandstraße 1, Leverkusen",5.0,1,"health, point_of_interest, establishment"
|
||||
marianna ozerova,"Bonner Str. 4, Leverkusen",3.9,11,"health, point_of_interest, establishment"
|
||||
Invictus Physiotherapie Leverkusen,"An d. Fuchskuhl 9b, Leverkusen",4.8,221,"physiotherapist, health, point_of_interest, establishment"
|
||||
Dr. med. Werner Ott Facharzt für Psychosomat. Med. und Psychotherapie,"Kölner Str. 79, Leverkusen",4.3,14,"doctor, health, point_of_interest, establishment"
|
||||
Physiotherapie am Fürstenbergplatz,"Fürstenbergpl. 4, Leverkusen",5.0,82,"health, point_of_interest, establishment"
|
||||
Physiotherapie Leverkusen-Quettingen - PhysioSport 360°,"Quettinger Str. 220, Leverkusen",4.9,111,"physiotherapist, health, point_of_interest, establishment"
|
||||
Dipl. Psych. Marlet Sina Klingauf,"Kölner Str. 79, Leverkusen",3.0,4,"health, point_of_interest, establishment"
|
||||
FZKL - Fortbildungszentrum Köln Leverkusen,"Entenpfuhl 25, Leverkusen",4.8,13,"physiotherapist, health, point_of_interest, establishment"
|
||||
Dr. Diana Enke Psychotherapeutische Praxis,"Kölner Str. 20A, Leverkusen",0.0,0,"health, point_of_interest, establishment"
|
||||
Psychotherapeutische Praxis für Kinder und Jugendliche | Svenja Lessing | Leverkusen,"Kölner Str. 20A, Leverkusen",0.0,0,"health, point_of_interest, establishment"
|
||||
Psychotherapie Valerie Stein,"Gisbert-Cremer-Straße 69, Leverkusen",0.0,0,"health, point_of_interest, establishment"
|
||||
Herr Dr. Khalil Al-Jaar,"Kölner Str. 36, Leverkusen",4.4,25,"health, point_of_interest, establishment"
|
||||
Praxis für Psychologische Psychotherapie,"Wilhelmstraße 12, Leverkusen",5.0,1,"health, point_of_interest, establishment"
|
||||
Privatpraxis Psychotherapie,"Talstraße 49, Leverkusen",0.0,0,"health, point_of_interest, establishment"
|
||||
Dipl.-Psych. Claudia Droste-Schmeißer,"Birkenbergstraße 14, Leverkusen",5.0,1,"health, point_of_interest, establishment"
|
||||
Praxis Stock Ergotherapie | Physiotherapie | Logopädie,"Kölner Str. 60, Leverkusen",4.2,17,"health, point_of_interest, establishment"
|
||||
Frau Dipl.-Psych. Monika Gfrörer,"Birkenbergstraße 14, Leverkusen",5.0,1,"health, point_of_interest, establishment"
|
||||
"Dr. Dipl.-Psych. Trientje Helbing, Praxis für Verhaltenstherapie","Kölner Str. 126, Leverkusen",5.0,5,"health, point_of_interest, establishment"
|
||||
Praxisgemeinschaft Ingrid Broch & Gisela Jachertz,"Düsseldorfer Str. 14, Leverkusen",5.0,2,"health, point_of_interest, establishment"
|
|
66
scrape_GoogleMaps/scrape.py
Normal file
66
scrape_GoogleMaps/scrape.py
Normal file
@@ -0,0 +1,66 @@
|
||||
import requests
|
||||
import pandas as pd
|
||||
|
||||
# Google API Key (ersetzen durch deinen Schlüssel)
|
||||
API_KEY = 'ENTER HERE'
|
||||
|
||||
# Base URL für die Google Places API
|
||||
BASE_URL = "https://maps.googleapis.com/maps/api/place/nearbysearch/json"
|
||||
|
||||
def search_places(query, location, radius=5000):
|
||||
"""
|
||||
Sucht Orte basierend auf Query und Standort.
|
||||
|
||||
:param query: Suchbegriff (z. B. 'Therapeuten')
|
||||
:param location: Standort als 'latitude,longitude'
|
||||
:param radius: Suchradius in Metern (Standard: 5000)
|
||||
:return: Liste von Orten
|
||||
"""
|
||||
params = {
|
||||
'key': API_KEY,
|
||||
'keyword': query,
|
||||
'location': location,
|
||||
'radius': radius
|
||||
}
|
||||
response = requests.get(BASE_URL, params=params, verify=False)
|
||||
if response.status_code == 200:
|
||||
return response.json().get('results', [])
|
||||
else:
|
||||
print(f"Error: {response.status_code}, {response.text}")
|
||||
return []
|
||||
|
||||
def save_to_csv(data, filename):
|
||||
"""
|
||||
Speichert die Daten in einer CSV-Datei.
|
||||
|
||||
:param data: Liste von Orten
|
||||
:param filename: Name der CSV-Datei
|
||||
"""
|
||||
df = pd.DataFrame(data)
|
||||
df.to_csv(filename, index=False)
|
||||
print(f"Datei gespeichert: {filename}")
|
||||
|
||||
def main():
|
||||
query = input("Gib den Suchbegriff ein (z. B. 'Therapeuten'): ")
|
||||
location = input("Gib den Standort ein (z. B. '52.5200,13.4050' für Berlin): ")
|
||||
radius = int(input("Gib den Suchradius in Metern ein (z. B. 5000): "))
|
||||
|
||||
places = search_places(query, location, radius)
|
||||
|
||||
if places:
|
||||
formatted_data = [
|
||||
{
|
||||
'Name': place.get('name'),
|
||||
'Adresse': place.get('vicinity'),
|
||||
'Bewertung': place.get('rating', 'N/A'),
|
||||
'Anzahl Bewertungen': place.get('user_ratings_total', 'N/A'),
|
||||
'Typ': ', '.join(place.get('types', []))
|
||||
}
|
||||
for place in places
|
||||
]
|
||||
save_to_csv(formatted_data, 'places.csv')
|
||||
else:
|
||||
print("Keine Ergebnisse gefunden.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user