I am trying to get strings from HTML using regular expression and it works on local html file. Only thing I need is to login on website using my program to get html from there.
The problem is that I tried logging in using 3 different codes without luck (I FOUND AL 3 CODES HERE). Website is HTTPS and also has no support for Internet Explorer. Don't want to use fiddler or any debugging tool. I don't care for speed, just want simple browser opening, signing in and getting html code from displayed content.
Is there any way to open chrome/mozilla/opera and transfer displayed HTML to my program? Or, if it's impossible, is there any some kind of universal way for signing in?
Is there any way to open chrome/mozilla/opera and transfer displayed HTML to my program?
You could use for example Selenium WebDriver for this. It will allow you to automate button pushing, text inputting etc. on the target web page. I wouldn't call it a "debugging tool", it's more like a testing framework. NuGet has all the packages you need:
There is a really neat usage sample here:
// Initialize the Chrome Driver
using (var driver = new ChromeDriver())
{
// Go to the home page
driver.Navigate().GoToUrl("https://yourdomainhere.net");
// Get the page elements
var userNameField = driver.FindElementById("username");
var userPasswordField = driver.FindElementById("password");
var loginButton = driver.FindElementByXPath("//input[@value='Login']");
// Type user name and password
userNameField.SendKeys("admin");
userPasswordField.SendKeys("12345");
// and click the login button
loginButton.Click();
// Extract the text and save it into result.txt
var result = driver.FindElementByXPath("//div[@id='case_login']/h3").Text;
File.WriteAllText("result.txt", result);
}
I am trying to get strings from HTML using regular expression
I have small hunch that you.. shouldn't. You can use the driver to extract the data you want from the page.