NOT DEBUGED YET. update of the updatedeposits function.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Deposits.SubDep;
|
||||
|
||||
namespace Deposits {
|
||||
class Program {
|
||||
public static bool ToEncrypt() {
|
||||
@@ -39,6 +38,7 @@ namespace Deposits {
|
||||
//Data data = new Data(true);
|
||||
//data.AddToData("{\"phone\":\"0547477082\"}");
|
||||
//System.Console.WriteLine("yes");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,12 +6,17 @@
|
||||
//using System.Runtime.InteropServices;
|
||||
//using Microsoft.Office.Interop.Excel;
|
||||
//using OfficeOpenXml.Core;
|
||||
//using HtmlAgilityPack;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Deposits.SubDep {
|
||||
class Excel {
|
||||
private static System.IO.FileInfo file = new System.IO.FileInfo(DataDetails.ExcelLocation);
|
||||
private OfficeOpenXml.ExcelPackage excelPackage = new OfficeOpenXml.ExcelPackage(file);
|
||||
public OfficeOpenXml.ExcelWorksheet deposits { get; }
|
||||
public OfficeOpenXml.ExcelWorksheet creditCard { get; }
|
||||
public OfficeOpenXml.ExcelWorksheet depositHistory { get; }
|
||||
public Excel() {
|
||||
var wb = excelPackage.Workbook;
|
||||
foreach (var sheet in wb.Worksheets) {
|
||||
@@ -19,6 +24,8 @@ namespace Deposits.SubDep {
|
||||
this.deposits = sheet;
|
||||
} else if (sheet.Name.Contains("credit")) {
|
||||
this.creditCard = sheet;
|
||||
} else if (sheet.Name.StartsWith("History")) {
|
||||
this.depositHistory = sheet;
|
||||
}
|
||||
}
|
||||
if (deposits == null) {
|
||||
@@ -27,10 +34,25 @@ namespace Deposits.SubDep {
|
||||
if (creditCard == null) {
|
||||
creditCard = wb.Worksheets.Add("credit card");
|
||||
}
|
||||
if (depositHistory == null) {
|
||||
creditCard = wb.Worksheets.Add("History of Deposits");
|
||||
}
|
||||
|
||||
}
|
||||
public void UpdateDeposits() {
|
||||
public void UpdateDeposits(string htmlPage) {
|
||||
HtmlAgilityPack.HtmlDocument document = new();
|
||||
document.LoadHtml(htmlPage);
|
||||
var s = document.DocumentNode.SelectNodes("//span");
|
||||
List<float> data = new List<float>();
|
||||
Regex regex = new Regex(@"(\d|.)+");
|
||||
|
||||
foreach (var item in s) {
|
||||
if (item.Attributes["class"].Name == "bigLobbyImageSum") {
|
||||
var v = regex.Match(item.Attributes["class"].Value).Value;
|
||||
data.Add(float.Parse(v));
|
||||
}
|
||||
}
|
||||
this.deposits.Cells["B2:B5"].Value = data.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -10,12 +10,12 @@ namespace Deposits.SubDep {
|
||||
Url = url;
|
||||
Mail = mail;
|
||||
this.Driver.Url = Url;
|
||||
Deposits.SubDep.Data data = new(true);
|
||||
Data = (JObject)data.DataJson["humail"];
|
||||
Data data = new(true);
|
||||
this.Data = (JObject)data.DataJson["humail"];
|
||||
}
|
||||
public void DefineMailApp() {
|
||||
this.MailApp = new();
|
||||
MailApp.RunWeb()
|
||||
MailApp.RunWeb();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,4 +1,6 @@
|
||||
using OpenQA.Selenium.Firefox;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
namespace Deposits.SubDep {
|
||||
class WebDriver {
|
||||
FirefoxOptions options = new();
|
||||
@@ -6,24 +8,27 @@ namespace Deposits.SubDep {
|
||||
string?[] Urls;
|
||||
public FirefoxDriver Driver;
|
||||
//JObject UrlAndActions
|
||||
public WebDriver() {
|
||||
CodePagesEncodingProvider.Instance.GetEncoding(437);
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
//System.IO.Path.Join("bins");
|
||||
SetOption();
|
||||
this.Driver = new("bins", this.options);
|
||||
}
|
||||
private void SetProfile() {
|
||||
this.profile.SetPreference("browser.download.folderList", 2);
|
||||
this.profile.SetPreference("browser.download.manager.showWhenStarting", false);
|
||||
//this.profile.SetPreference("browser.download.manager.showWhenStarting", false);
|
||||
this.profile.SetPreference("browser.download.dir", "D:/Neutral Folder/");
|
||||
this.profile.SetPreference("browser.helperApps.neverAsk.saveToDisk", "attachment/csv, text/plain, application/octet-stream, application/binary, text/csv, application/csv, application/excel, text/comma-separated-values, text/xml, application/xml, application/xls, excel/xls, application/excel 97-2003,application/Microsoft Excel 97-2003 Worksheet, application/vnd.ms-excel");
|
||||
this.profile.SetPreference("browser.helperApps.neverAsk.openFile", "application/PDF, application/FDF, application/XFDF, application/LSL, application/LSO, application/LSS, application/IQY, application/RQY, application/XLK, application/XLS, application/XLT, application/POT application/PPS, application/PPT, application/DOS, application/DOT, application/WKS, application/BAT, application/PS, application/EPS, application/WCH, application/WCM, application/WB1, application/WB3, application/RTF, application/DOC, application/MDB, application/MDE, application/WBK, application/WB1, application/WCH, application/WCM, application/AD, application/ADP, application/vnd.ms-excel");
|
||||
this.profile.SetPreference("browser.download.panel.shown", false);
|
||||
|
||||
}
|
||||
private void SetOption() {
|
||||
SetProfile();
|
||||
this.options.Profile = this.profile;
|
||||
this.options.AddArgument("--lang=EN");
|
||||
}
|
||||
public WebDriver() {
|
||||
//System.IO.Path.Join("bins\\geckodriver.exe");
|
||||
SetOption();
|
||||
this.Driver = new($"bins", options);
|
||||
}
|
||||
public void RunWeb(int timeToWait = 0, params string[] urls) {
|
||||
//System.Timers.Timer timer = new(timeToWait * 1000);
|
||||
foreach (var url in urls) {
|
||||
@@ -31,5 +36,27 @@ namespace Deposits.SubDep {
|
||||
System.Threading.Thread.Sleep(timeToWait * 1000);
|
||||
}
|
||||
}
|
||||
public void EnterDataToWeb(string url, Dictionary<string, string> idToData) {
|
||||
Driver.Url = url;
|
||||
var v = "";
|
||||
System.Threading.Thread.Sleep(30000);
|
||||
try {
|
||||
foreach (var dataid in idToData) {
|
||||
Driver.FindElementById(dataid.Key).SendKeys(dataid.Value);
|
||||
System.Threading.Thread.Sleep(100);
|
||||
v = dataid.Key;
|
||||
}
|
||||
Driver.FindElementById(v).SendKeys(OpenQA.Selenium.Keys.Enter);
|
||||
|
||||
} catch {
|
||||
foreach (var dataid in idToData) {
|
||||
Driver.FindElementByName(dataid.Key).SendKeys(dataid.Value.Split('@')[0]);
|
||||
System.Threading.Thread.Sleep(100);
|
||||
v = dataid.Key;
|
||||
}
|
||||
Driver.FindElementByName(v).SendKeys(OpenQA.Selenium.Keys.Enter);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user