Basically the site I am trying to scrape text from is secure and only accessible to those on what i can assume is the VPN the organization has set.
When I was testing my tool today, while connected to the network at this place, on a computer that can access this site, it was not allowing the tool to access it. I am wondering if maybe there's something im missing that someone can tell me.
Below I have attached my entire source code. For context and a better understanding, the fields for "Demo Results" are just to test on any site. Currently i have it so that i can paste whatever xPath and URL i please in a textbox. This will be changed later and set to a specific URL and xPath. I am using HTMLAgilityPack as you might see. This works when i use it on any site that is accessible to the public. But when it comes to this specific site, I get an error that the object is not set to an instance of an object. The site works 100% fine in the web browser.
namespace ToolConcept
{
public partial class Form1 : Form
{
public string Results1;
public string Results2;
public string DemoResults;
public Form1()
{
InitializeComponent();
DemoResults = "";
Results1 = "YOUR RESULTS HERE";
Results2 = "RESULTS SHOWN HERE!";
}
public void Scrape(string args)
{
HtmlAgilityPack.HtmlWeb web = new HtmlAgilityPack.HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = web.Load(urlField.Text);
foreach(var item in doc.DocumentNode.SelectNodes(pathField.Text))
{
DemoResults = item.InnerText;
}
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "R1")
{
textBox2.Text = Results1;
}
else if (textBox1.Text == "R2")
{
textBox2.Text = Results1 + Results2;
}
else if (textBox1.Text == "0")
{
Scrape(DemoResults);
HtmlAgilityPack.HtmlWeb search = new HtmlAgilityPack.HtmlWeb();
textBox2.Text = DemoResults;
}
if(textBox1.Text == null)
{
MessageBox.Show("Not Found!");
}
}
private void button2_Click(object sender, EventArgs e)
{
textBox2.Clear();
}
}
}