我在 C# 中构建了一个简单的应用程序,该应用程序将新链接发布到 google+ 帐户,但它正在启动实际的浏览器本身。我对 C#、Python、PHP 语言甚至其他语言都很好。
我不能使用 C# WebClient 类,因为许多交互都是基于 JS 的,所以我需要以某种方式模拟浏览器。
这是我的硒 C# 代码,因此您可以理解我想要实现的目标。
static void Main(string[] args)
{
IWebDriver driver;
FirefoxProfile firefoxProfile = new FirefoxProfile();
driver = new FirefoxDriver();
driver.Navigate().GoToUrl("https://accounts.google.com/ServiceLoginAuth");
driver.FindElement(By.Name("Email")).SendKeys("MYEMAIL");
driver.FindElement(By.Name("Passwd")).SendKeys("MYPASSWORD");
driver.FindElement(By.Name("signIn")).Click();
driver.Navigate().GoToUrl("https://plusone.google.com/_/+1/confirm?hl=en&url=http://site.com/");
System.Threading.Thread.Sleep(10000);
driver.FindElement(By.ClassName("e-U-a-fa")).Click();
Console.WriteLine("Done!");
Console.ReadLine();
}