diff --git a/webCrawlerGoogle.sln b/webCrawlerGoogle.sln
new file mode 100644
index 0000000..c1cbc0e
--- /dev/null
+++ b/webCrawlerGoogle.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.10.35122.118
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "webCrawlerGoogle", "webCrawlerGoogle\webCrawlerGoogle.csproj", "{36E507D2-6D2C-43DD-9E30-F7E151018942}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {36E507D2-6D2C-43DD-9E30-F7E151018942}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {36E507D2-6D2C-43DD-9E30-F7E151018942}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {36E507D2-6D2C-43DD-9E30-F7E151018942}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {36E507D2-6D2C-43DD-9E30-F7E151018942}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {FB32F52A-3116-4EB2-A3D9-B6435A5B7A2E}
+ EndGlobalSection
+EndGlobal
diff --git a/webCrawlerGoogle/Form1.Designer.cs b/webCrawlerGoogle/Form1.Designer.cs
new file mode 100644
index 0000000..f1ec423
--- /dev/null
+++ b/webCrawlerGoogle/Form1.Designer.cs
@@ -0,0 +1,97 @@
+namespace webCrawlerGoogle
+{
+ partial class Form1
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.txtCategory = new System.Windows.Forms.TextBox();
+ this.txtCity = new System.Windows.Forms.TextBox();
+ this.btnSearch = new System.Windows.Forms.Button();
+ this.lstResults = new System.Windows.Forms.ListBox();
+ this.SuspendLayout();
+
+ //
+ // txtCategory
+ //
+ this.txtCategory.Location = new System.Drawing.Point(12, 12);
+ this.txtCategory.Name = "txtCategory";
+ this.txtCategory.Size = new System.Drawing.Size(260, 20);
+ this.txtCategory.TabIndex = 0;
+ this.txtCategory.PlaceholderText = "Rubrik (z.B. Restaurant)";
+
+ //
+ // txtCity
+ //
+ this.txtCity.Location = new System.Drawing.Point(12, 38);
+ this.txtCity.Name = "txtCity";
+ this.txtCity.Size = new System.Drawing.Size(260, 20);
+ this.txtCity.TabIndex = 1;
+ this.txtCity.PlaceholderText = "Stadt (z.B. Berlin)";
+
+ //
+ // btnSearch
+ //
+ this.btnSearch.Location = new System.Drawing.Point(12, 64);
+ this.btnSearch.Name = "btnSearch";
+ this.btnSearch.Size = new System.Drawing.Size(260, 23);
+ this.btnSearch.TabIndex = 2;
+ this.btnSearch.Text = "Suchen";
+ this.btnSearch.UseVisualStyleBackColor = true;
+ this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
+
+ //
+ // lstResults
+ //
+ this.lstResults.FormattingEnabled = true;
+ this.lstResults.Location = new System.Drawing.Point(12, 93);
+ this.lstResults.Name = "lstResults";
+ this.lstResults.Size = new System.Drawing.Size(260, 147);
+ this.lstResults.TabIndex = 3;
+
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(284, 261);
+ this.Controls.Add(this.lstResults);
+ this.Controls.Add(this.btnSearch);
+ this.Controls.Add(this.txtCity);
+ this.Controls.Add(this.txtCategory);
+ this.Name = "Form1";
+ this.Text = "Google Business Suche";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+ }
+
+ #endregion
+ private System.Windows.Forms.TextBox txtCategory;
+ private System.Windows.Forms.TextBox txtCity;
+ private System.Windows.Forms.Button btnSearch;
+ private System.Windows.Forms.ListBox lstResults;
+ }
+}
diff --git a/webCrawlerGoogle/Form1.cs b/webCrawlerGoogle/Form1.cs
new file mode 100644
index 0000000..bd94e70
--- /dev/null
+++ b/webCrawlerGoogle/Form1.cs
@@ -0,0 +1,101 @@
+using MySql.Data.MySqlClient;
+using Newtonsoft.Json.Linq;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;
+
+namespace webCrawlerGoogle
+{
+ public partial class Form1 : Form
+ {
+ private const string ApiKey = "AIzaSyCjdysuuyc2bs4ikqT8xyIpPJHiDZ4CEo4"; // Füge hier deinen API-Schlüssel ein
+ private string connectionString = "Server=192.168.178.201;Database=domainchecker;User ID=root;Password=1td5rugut8;";
+
+ public Form1()
+ {
+ InitializeComponent();
+ }
+
+ private async void btnSearch_Click(object sender, EventArgs e)
+ {
+ string category = txtCategory.Text;
+ string city = txtCity.Text;
+
+ if (string.IsNullOrEmpty(category) || string.IsNullOrEmpty(city))
+ {
+ MessageBox.Show("Bitte sowohl eine Rubrik als auch eine Stadt eingeben.");
+ return;
+ }
+
+ string requestUri = $"https://maps.googleapis.com/maps/api/place/textsearch/json?query={category}+in+{city}&key={ApiKey}";
+
+ using (HttpClient client = new HttpClient())
+ {
+ HttpResponseMessage response = await client.GetAsync(requestUri);
+ if (response.IsSuccessStatusCode)
+ {
+ string jsonResult = await response.Content.ReadAsStringAsync();
+ JObject result = JObject.Parse(jsonResult);
+
+ lstResults.Items.Clear();
+
+ foreach (var place in result["results"])
+ {
+ string website = await GetPlaceDetails((string)place["place_id"]);
+ if (!string.IsNullOrEmpty(website))
+ {
+ lstResults.Items.Add(website);
+ SaveToDatabase(website);
+ }
+ }
+ }
+ else
+ {
+ MessageBox.Show("Fehler bei der Anfrage: " + response.StatusCode);
+ }
+ }
+ }
+
+ private async Task GetPlaceDetails(string placeId)
+ {
+ string requestUri = $"https://maps.googleapis.com/maps/api/place/details/json?place_id={placeId}&fields=website&key={ApiKey}";
+
+ using (HttpClient client = new HttpClient())
+ {
+ HttpResponseMessage response = await client.GetAsync(requestUri);
+ if (response.IsSuccessStatusCode)
+ {
+ string jsonResult = await response.Content.ReadAsStringAsync();
+ JObject result = JObject.Parse(jsonResult);
+
+ return (string)result["result"]["website"];
+ }
+
+ return null;
+ }
+ }
+
+ private void SaveToDatabase(string website)
+ {
+ using (MySqlConnection conn = new MySqlConnection(connectionString))
+ {
+ conn.Open();
+ string queryCheck = "SELECT COUNT(*) FROM webCrawler WHERE webseite = @website";
+ using (MySqlCommand cmdCheck = new MySqlCommand(queryCheck, conn))
+ {
+ cmdCheck.Parameters.AddWithValue("@website", website);
+ int count = Convert.ToInt32(cmdCheck.ExecuteScalar());
+
+ if (count == 0)
+ {
+ string queryInsert = "INSERT INTO webCrawler (webseite) VALUES (@website)";
+ using (MySqlCommand cmdInsert = new MySqlCommand(queryInsert, conn))
+ {
+ cmdInsert.Parameters.AddWithValue("@website", website);
+
+ cmdInsert.ExecuteNonQuery();
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/webCrawlerGoogle/Form1.resx b/webCrawlerGoogle/Form1.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/webCrawlerGoogle/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/webCrawlerGoogle/Program.cs b/webCrawlerGoogle/Program.cs
new file mode 100644
index 0000000..0d279ed
--- /dev/null
+++ b/webCrawlerGoogle/Program.cs
@@ -0,0 +1,17 @@
+namespace webCrawlerGoogle
+{
+ internal static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ // To customize application configuration such as set high DPI settings or default font,
+ // see https://aka.ms/applicationconfiguration.
+ ApplicationConfiguration.Initialize();
+ Application.Run(new Form1());
+ }
+ }
+}
\ No newline at end of file
diff --git a/webCrawlerGoogle/webCrawlerGoogle.csproj b/webCrawlerGoogle/webCrawlerGoogle.csproj
new file mode 100644
index 0000000..9addb57
--- /dev/null
+++ b/webCrawlerGoogle/webCrawlerGoogle.csproj
@@ -0,0 +1,16 @@
+
+
+
+ WinExe
+ net8.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
+
\ No newline at end of file