Compare commits
2 Commits
6c216ca189
...
c78d734d14
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c78d734d14 | ||
|
|
b566b0a201 |
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Selenium.WebDriver" Version="4.11.0" />
|
<PackageReference Include="Selenium.WebDriver" Version="4.22.0" />
|
||||||
|
<PackageReference Include="Selenium.WebDriver.GeckoDriver" Version="0.35.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
// See https://aka.ms/new-console-template for more information
|
// See https://aka.ms/new-console-template for more information
|
||||||
|
|
||||||
using OpenQA.Selenium.Chrome;
|
using OpenQA.Selenium.Chrome;
|
||||||
|
//using SeleniumUndetectedChromeDriver;
|
||||||
using OpenQA.Selenium;
|
using OpenQA.Selenium;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using ConsoleApp3.Contracts;
|
using ConsoleApp3.Contracts;
|
||||||
|
using static System.Collections.Specialized.BitVector32;
|
||||||
|
|
||||||
namespace CardmarketBot
|
namespace CardmarketBot
|
||||||
{
|
{
|
||||||
@@ -31,19 +33,45 @@ namespace CardmarketBot
|
|||||||
|
|
||||||
public List<Kunde> ParseCardMarket(string forceid = "")
|
public List<Kunde> ParseCardMarket(string forceid = "")
|
||||||
{
|
{
|
||||||
|
//var driver = UndetectedChromeDriver.Create(driverExecutablePath: await new ChromeDriverInstaller().Auto());
|
||||||
|
|
||||||
ChromeOptions options = new ChromeOptions();
|
ChromeOptions options = new ChromeOptions();
|
||||||
options.AddArgument("start-maximized");
|
options.AddArgument("start-maximized");
|
||||||
options.AddArgument("incognito");
|
//options.AddArgument("incognito");
|
||||||
options.AddArgument("disable-popup-blocking");
|
options.AddArgument("disable-popup-blocking");
|
||||||
options.AddArgument("force-device-scale-factor=0.8");
|
options.AddArgument("force-device-scale-factor=0.8");
|
||||||
|
//options.AddArgument("lang=en");
|
||||||
IWebDriver cd = new ChromeDriver(options);
|
IWebDriver cd = new ChromeDriver(options);
|
||||||
|
|
||||||
|
//driver.GoToUrl("https://www.cardmarket.com/de/OnePiece");
|
||||||
|
|
||||||
|
|
||||||
cd.Url = @"https://www.cardmarket.com/de/OnePiece";
|
cd.Url = @"https://www.cardmarket.com/de/OnePiece";
|
||||||
|
|
||||||
cd.Navigate();
|
cd.Navigate();
|
||||||
|
|
||||||
cd.FindElement(By.CssSelector("#CookiesConsent > div > div > form > button")).Click();
|
Thread.Sleep(2000);
|
||||||
Thread.Sleep(10);
|
|
||||||
|
IWebElement? element;
|
||||||
|
|
||||||
|
/*
|
||||||
|
bool cloudfire = true;
|
||||||
|
|
||||||
|
|
||||||
|
if (cloudfire)
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
Console.WriteLine("Scheint als würde Cloudfire aktiviert sein.");
|
||||||
|
Console.WriteLine("Bitte bestätige und komme zurück und klicke die buchstabe c und Enter");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
cd.FindElement(By.CssSelector("#CookiesConsent > div > div > form > div > button")).Click();
|
||||||
|
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
|
||||||
cd.FindElement(By.Name("username")).Click();
|
cd.FindElement(By.Name("username")).Click();
|
||||||
cd.FindElement(By.Name("username")).SendKeys(username);
|
cd.FindElement(By.Name("username")).SendKeys(username);
|
||||||
|
|
||||||
@@ -52,6 +80,8 @@ namespace CardmarketBot
|
|||||||
|
|
||||||
cd.FindElement(By.CssSelector("#header-login > input.btn.btn-outline-primary.btn-sm")).Click();
|
cd.FindElement(By.CssSelector("#header-login > input.btn.btn-outline-primary.btn-sm")).Click();
|
||||||
|
|
||||||
|
Thread.Sleep(6000);
|
||||||
|
|
||||||
|
|
||||||
CookieContainer cookieContainer = new CookieContainer();
|
CookieContainer cookieContainer = new CookieContainer();
|
||||||
foreach (var c in cd.Manage().Cookies.AllCookies)
|
foreach (var c in cd.Manage().Cookies.AllCookies)
|
||||||
@@ -63,11 +93,47 @@ namespace CardmarketBot
|
|||||||
|
|
||||||
List<string> ids = new List<string>();
|
List<string> ids = new List<string>();
|
||||||
List<Kunde> kunden = new List<Kunde>();
|
List<Kunde> kunden = new List<Kunde>();
|
||||||
IWebElement element;
|
//IWebElement? element;
|
||||||
|
|
||||||
|
/*cloudfire = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
element = cd.FindElement(By.XPath("/html/body/div[1]/div/div[1]/div"));
|
||||||
|
|
||||||
|
// //[@id="challenge-body-text"]
|
||||||
|
}
|
||||||
|
catch (NoSuchElementException)
|
||||||
|
{
|
||||||
|
cloudfire = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine(cloudfire);
|
||||||
|
|
||||||
|
if(cloudfire )
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
Console.WriteLine("Scheint als würde Cloudfire aktiviert sein.");
|
||||||
|
Console.WriteLine("Bitte bestätige und komme zurück und klicke die buchstabe c und Enter");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
if (forceid != "")
|
if (forceid != "")
|
||||||
{
|
{
|
||||||
ids.Add(forceid);
|
string[] mid = forceid.Split(',');
|
||||||
|
if (mid.Length < 0)
|
||||||
|
{
|
||||||
|
ids.Add(forceid);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach(string kid in mid)
|
||||||
|
{
|
||||||
|
ids.Add(kid);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -75,15 +141,16 @@ namespace CardmarketBot
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
element = cd.FindElement(By.XPath("/html/body/main/section/div[3]/div[4]"));
|
var verkaufstable = cd.FindElements(By.XPath("/html/body/main/section/div[3]/div[4]/div[2]/*"));
|
||||||
|
|
||||||
string content = element.Text;
|
foreach(var karte in verkaufstable)
|
||||||
string[] datas = content.Split("\r\n");
|
|
||||||
|
|
||||||
for (int i = 8; i < datas.Length; i += 7)
|
|
||||||
{
|
{
|
||||||
ids.Add(datas[i]);
|
var content = karte.Text.Split("\r\n");
|
||||||
|
// 10 Stellen ist die ID
|
||||||
|
ids.Add(content[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (OpenQA.Selenium.NotFoundException)
|
catch (OpenQA.Selenium.NotFoundException)
|
||||||
{
|
{
|
||||||
@@ -123,7 +190,11 @@ namespace CardmarketBot
|
|||||||
|
|
||||||
|
|
||||||
// Artikeln
|
// Artikeln
|
||||||
element = cd.FindElement(By.XPath("/html/body/main/section/div/div[1]/div/div[5]/table/tbody"));
|
var k = cd.FindElements(By.XPath("/html/body/main/section/div/div[1]/div/*/table"));
|
||||||
|
//Debugger.Break();
|
||||||
|
element = k[0];
|
||||||
|
//element = cd.FindElement(By.XPath("/html/body/main/section/div/div[1]/div/div[6]/table/tbody"));
|
||||||
|
//element = cd.FindElement(By.XPath("/html/body/main/section/div/div[1]/div/div[5]/table/tbody"));
|
||||||
string artikeln = element.Text;
|
string artikeln = element.Text;
|
||||||
kunde.Artikels = Helper.ParseArtikeln(element.Text);
|
kunde.Artikels = Helper.ParseArtikeln(element.Text);
|
||||||
|
|
||||||
|
|||||||
38
CardMarketBot/CheckSevDeskInternalList.cs
Normal file
38
CardMarketBot/CheckSevDeskInternalList.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using ConsoleApp3.Contracts;
|
||||||
|
|
||||||
|
namespace CardmarketBot
|
||||||
|
{
|
||||||
|
internal class CheckSevDeskInternalList : ICheckSevDesk
|
||||||
|
{
|
||||||
|
private const string FILENAME = "usedList.csv";
|
||||||
|
|
||||||
|
private List<string> Query => (from l in File.ReadAllLines("usedList.csv")
|
||||||
|
select l.Split(',') into p
|
||||||
|
select new string(p[0])).ToList();
|
||||||
|
|
||||||
|
public CheckSevDeskInternalList()
|
||||||
|
{
|
||||||
|
if (!File.Exists("usedList.csv"))
|
||||||
|
{
|
||||||
|
File.Create("usedList.csv");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AlreadyKnown(string verkaufsnummer)
|
||||||
|
{
|
||||||
|
if (Query.Find((string x) => x.Equals(verkaufsnummer)) != null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Write(string verkaufsnummer)
|
||||||
|
{
|
||||||
|
verkaufsnummer += Environment.NewLine;
|
||||||
|
File.AppendAllText("usedList.csv", verkaufsnummer);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -90,7 +90,7 @@ namespace CardMarketBot
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TcpClient client = new TcpClient("nas.cosysda.de", 4000);
|
TcpClient client = new TcpClient("huskyteufel.ddnss.de", 4000);
|
||||||
Write(client, string.Format("#TEST#{0}", verkaufsnummer));
|
Write(client, string.Format("#TEST#{0}", verkaufsnummer));
|
||||||
EResult result = Read(client);
|
EResult result = Read(client);
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ namespace CardMarketBot
|
|||||||
|
|
||||||
return result == EResult.OK;
|
return result == EResult.OK;
|
||||||
}
|
}
|
||||||
catch(SocketException)
|
catch(SocketException ex)
|
||||||
{
|
{
|
||||||
throw new SocketException();
|
throw new SocketException();
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ namespace CardMarketBot
|
|||||||
|
|
||||||
public bool Write(string verkaufsnummer)
|
public bool Write(string verkaufsnummer)
|
||||||
{
|
{
|
||||||
TcpClient client = new TcpClient("nas.cosysda.de", 4000);
|
TcpClient client = new TcpClient("huskyteufel.ddnss.de", 4000);
|
||||||
Write(client, string.Format("#WRITE#{0}", verkaufsnummer));
|
Write(client, string.Format("#WRITE#{0}", verkaufsnummer));
|
||||||
EResult result = Read(client);
|
EResult result = Read(client);
|
||||||
client.Client.Shutdown(SocketShutdown.Both);
|
client.Client.Shutdown(SocketShutdown.Both);
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ public static class Helper
|
|||||||
}
|
}
|
||||||
internal static Kunde ConvertToKunde(string text)
|
internal static Kunde ConvertToKunde(string text)
|
||||||
{
|
{
|
||||||
|
|
||||||
string[] datas = text.Split("\r\n");
|
string[] datas = text.Split("\r\n");
|
||||||
string name = datas[0];
|
string name = datas[0];
|
||||||
string adresseUNDHausnummer = datas[datas.Length-3];
|
string adresseUNDHausnummer = datas[datas.Length-3];
|
||||||
@@ -31,7 +30,7 @@ public static class Helper
|
|||||||
datas = adresseUNDHausnummer.Split(" ");
|
datas = adresseUNDHausnummer.Split(" ");
|
||||||
string strasse = "";
|
string strasse = "";
|
||||||
string hausnummer = "";
|
string hausnummer = "";
|
||||||
Trace.WriteLine(datas.Length);
|
//Trace.WriteLine(datas.Length);
|
||||||
if (datas.Length <= 1)
|
if (datas.Length <= 1)
|
||||||
{
|
{
|
||||||
Regex myRegex = new Regex("[0-9]*$");
|
Regex myRegex = new Regex("[0-9]*$");
|
||||||
@@ -49,7 +48,6 @@ public static class Helper
|
|||||||
hausnummer = datas[datas.Length - 1];
|
hausnummer = datas[datas.Length - 1];
|
||||||
}
|
}
|
||||||
return new Kunde(name, strasse, hausnummer, plz, ort, land);
|
return new Kunde(name, strasse, hausnummer, plz, ort, land);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Artikel> ParseArtikeln(string text)
|
public static List<Artikel> ParseArtikeln(string text)
|
||||||
@@ -105,7 +103,7 @@ public static class Helper
|
|||||||
temp.Source = datas[j];
|
temp.Source = datas[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Trace.WriteLine(j + " " + datas[j]);
|
//Trace.WriteLine(j + " " + datas[j]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -129,26 +127,4 @@ public static class Helper
|
|||||||
|
|
||||||
return DateTime.Parse(string.Format("{0} {1}", datum, uhrzeit));
|
return DateTime.Parse(string.Format("{0} {1}", datum, uhrzeit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create(@"https://www.cardmarket.com/de/OnePiece/Orders/Sales/Paid");
|
|
||||||
hwr.CookieContainer = cookieContainer;
|
|
||||||
hwr.Method = "GET";
|
|
||||||
hwr.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36";
|
|
||||||
WebResponse wr = hwr.GetResponse();
|
|
||||||
string s = new StreamReader(wr.GetResponseStream()).ReadToEnd();
|
|
||||||
Console.WriteLine(s);
|
|
||||||
|
|
||||||
string GetHashKey(string line)
|
|
||||||
{
|
|
||||||
var x = line.IndexOf("__cmtkn");
|
|
||||||
var d = line.Substring(x + 16);
|
|
||||||
var m = d.IndexOf("\"");
|
|
||||||
var a = d.Substring(0, m);
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
@@ -2,27 +2,61 @@
|
|||||||
using ConsoleApp3.Contracts;
|
using ConsoleApp3.Contracts;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using CardMarketBot;
|
using CardMarketBot;
|
||||||
using OpenQA.Selenium.DevTools.V113.Network;
|
|
||||||
using System.Reflection.Metadata.Ecma335;
|
using System.Reflection.Metadata.Ecma335;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
namespace CardmarketBot
|
namespace CardmarketBot
|
||||||
{
|
{
|
||||||
internal class Programm
|
internal class Programm
|
||||||
{
|
{
|
||||||
|
private static bool CheckServerAvaible()
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
IPAddress[] hostAddresses = Dns.GetHostAddresses("huskyteufel.ddnss.de");
|
||||||
|
if (hostAddresses.Length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
IPEndPoint iPEndPoint = new IPEndPoint(hostAddresses[0], 4000);
|
||||||
|
Socket socket = new Socket(iPEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
socket.Connect(iPEndPoint);
|
||||||
|
if (socket.Connected)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
ICheckSevDesk checkSevDesk = new CheckSevDeskPublicList();
|
Console.WriteLine("Hendrik prüft ob Server erreichbar ist");
|
||||||
|
bool flag = CheckServerAvaible();
|
||||||
|
Console.WriteLine("Das ergebnis von Hendrik seine erkundung lautet: " + flag);
|
||||||
|
|
||||||
Console.WriteLine("Hallo Herzlich willkommen beim Junker sein Junker der im Junkerloch junkert");
|
ICheckSevDesk checkSevDesk = ((!flag) ? ((ICheckSevDesk)new CheckSevDeskInternalList()) : ((ICheckSevDesk)new CheckSevDeskPublicList()));
|
||||||
|
|
||||||
|
|
||||||
|
Console.WriteLine("Hallo Herzlich willkommen Augustin Karneval e.V.");
|
||||||
Console.WriteLine("Was kann ich für dich tun?");
|
Console.WriteLine("Was kann ich für dich tun?");
|
||||||
bool programmexited = false;
|
bool programmexited = false;
|
||||||
List<Kunde> kunden = new List<Kunde>();
|
List<Kunde> kunden = new List<Kunde>();
|
||||||
CardMarketParser cardMarketParser = new CardMarketParser("More-Tcg", "Magnatpower310!!");
|
CardMarketParser cardMarketParser = new CardMarketParser("More-Tcg", "Magnatpower310!!");
|
||||||
while (!programmexited)
|
while (!programmexited)
|
||||||
{
|
{
|
||||||
Console.WriteLine("1) Starte den Hugo, der alle bezahlte Artikeln erfasst");
|
Console.WriteLine("1) Starte den Konstantin, der alle bezahlte Artikeln erfasst");
|
||||||
Console.WriteLine("2) Starte den Rolfes der Bestellnummern nachkontrolliert");
|
Console.WriteLine("2) Starte den Pöttker der Bestellnummern nachkontrolliert");
|
||||||
Console.WriteLine("3) Beende");
|
Console.WriteLine("3) Reset der Augen, gut wenn man Pöttkers Frau gesehen hat");
|
||||||
|
Console.WriteLine("4) Beende");
|
||||||
string? input = Console.ReadLine();
|
string? input = Console.ReadLine();
|
||||||
if (input == null)
|
if (input == null)
|
||||||
{
|
{
|
||||||
@@ -48,11 +82,15 @@ namespace CardmarketBot
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "3":
|
case "3":
|
||||||
|
DoShit();
|
||||||
|
break;
|
||||||
|
case "4":
|
||||||
programmexited = true;
|
programmexited = true;
|
||||||
continue;
|
continue;
|
||||||
default: continue;
|
default: continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Rechnungen generieren
|
// Rechnungen generieren
|
||||||
List<ModelRechnung> rechnungen = new List<ModelRechnung>();
|
List<ModelRechnung> rechnungen = new List<ModelRechnung>();
|
||||||
@@ -85,11 +123,27 @@ namespace CardmarketBot
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Post CSV Erstellen
|
// Post CSV Erstellen
|
||||||
DeutschePost deutschePost = new DeutschePost(kunden);
|
//DeutschePost deutschePost = new DeutschePost(kunden);
|
||||||
deutschePost.GenerateCSV();
|
//deutschePost.GenerateCSV();
|
||||||
|
|
||||||
Console.WriteLine("Fertig");
|
Console.WriteLine("Fertig");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void DoShit()
|
||||||
|
{
|
||||||
|
|
||||||
|
for(int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
Console.Beep(38, 3);
|
||||||
|
Console.BackgroundColor = ConsoleColor.Green;
|
||||||
|
Console.Clear();
|
||||||
|
Thread.Sleep(100);
|
||||||
|
Console.BackgroundColor = ConsoleColor.Red;
|
||||||
|
Console.Clear();
|
||||||
|
}
|
||||||
|
Console.BackgroundColor = ConsoleColor.Black;
|
||||||
|
Console.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user