LinkFinder.find fails to work in webcrawler app - c#

Wrote code as the start to a web crawler that scrapes links from webpage.
Following the instructions from this page:
http://www.dotnetperls.com/scraping-html
I seem to get an error that LinkFinder cannot be found?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Diagnostics;
namespace WebCrawler
{
class Program
{
static void Main(string[] args)
{
WebClient url = new WebClient();
String initialLink = url.DownloadString("http://www.FAKEADDRESS.org.uk/");
for (LinkItem i in LinkFinder.find(initialLink))
{
System.Diagnostics.Debug.WriteLine(initialLink);
}
}
}
}

LinkFinder is a class that is included in the code at that URL you provided. Make sure you also copy that class into your project in some way (a file by itself, in another file, whatever).

Related

How to get a number related to a string from HTML

In a website we have a code like this
<td>TheNumber</td>
<td>ACode</td>
<td style="width:350px;">A Special String For The Number</td>
I want to create an app that the users write the string and the app get 'TheNumber' from website according to the string.
Can we write an app like this in c#?
You can use HTML Agility Pack to manipulate HTML documents.
sample code
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using HtmlAgilityPack;
public class Program
{
public static void Main()
{
// Load
var doc = new HtmlDocument();
doc.LoadHtml(#"<td>TheNumber</td><td>ACode</td><td style='width:350px;'>A Special String For The Number</td>");
var div = doc.DocumentNode.ChildNodes.Where(t => t.InnerText == "A Special String For The Number").ToList().FirstOrDefault();
// Show info
System.Console.WriteLine(div.PreviousSibling.InnerText);
System.Console.WriteLine(div.PreviousSibling.PreviousSibling.InnerText);
}
}

this api script for a app for a site i made is not working

I need help with this
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace kbam_.API
{
class filea
{
public static string filea(string url) //this code right here
{
string contents;
var wc = new System.Net.WebClient();
contents = wc.DownloadString(url);
}
}
}
and yes I am authorized by kesbook uk to use this I'm the owner so I can use what I want http://kesbook.cf/autho
If you are querying a a RESTful API I would suggest using the Restsharp nugget package, it is much easier to use.

How to print out the result of a SWI-Prolog query from C# using Swi-cs-pl library

I'm trying to understand how the Swi-cs-pl library works by doing my own little program, but I cannot printout any result from a query based on the example from SWI-Prolog web.
I have this code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SbsSW.SwiPlCs;
namespace HolaMundo
{
class Program
{
static void Main(string[] args)
{
if (!PlEngine.IsInitialized)
{
String[] param = { "-q" }; // suppressing informational and banner messages
PlEngine.Initialize(param);
PlQuery.PlCall("assert(father(hader, nevar))");
PlQuery.PlCall("assert(father(hader, sergio))");
PlQuery.PlCall("assert(brother(nevar, sergio):- father(hader, nevar), father(hader, sergio))");
//How do I write out in a Console the answer for a query like:
// brother(nevar, sergio)
PlEngine.PlCleanup();
}
}
}
}
As I said on my code, I just want to query something basic like: brother(nevar, sergio). and get any answer from Console like true or whatever.
Can anyone help me?

FTP C# console 2010 sending data.dat file of 71kb i get a file in my ftp but it is 0byte

okay so basically I am using the class object from here
http://www.codeproject.com/Tips/443588/Simple-Csharp-FTP-Class
I have then created my main program file here it is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
/* Create Object Instance */
ftp ftpClient = new ftp(#"ftp://ftp.drivehq.com/", "ashg1990", "Robert12");
/* Upload a File */
ftpClient.upload("stat.dat", #"C:\Users\ash\AppData\Roaming\EruptMiner\Stats.dat");
}
}
}
this code works to a degree but the file I get is a 0byte one so it not the original and is blank can any one help me

C# Web Reference and PHP

I am attempting to call a Web Service (created in PHP) from my C# application. I have successfully added the Web Reference in Visual Studios, however I cannot figure out exactly how to invoke the call to the web service. I have been following this tutorial: http://sanity-free.org/article25.html however when I try and compile I get a "The type or namespace name 'SimpleService' could not be found". My C# code is as follows:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace inVision_OCR
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void translateButton_Click(object sender, EventArgs e)
{
// We need to snap the image here somehow . . .
// Open up the image and read its contents into a string
FileStream file = new FileStream("\\Hard Disk\\ocr_images\\test.jpg", FileMode.Open);
StreamReader sr = new StreamReader(file);
string s = sr.ReadToEnd();
sr.Close();
// Using SOAP, pass this message to our development server
SimpleService svc = new SimpleService();
string s1 = svc.getOCR("test");
MessageBox.Show(s);
}
}
}
The SimpleService is probably in a different namespace, look at the properties of the web reference you added and see what namespace the proxy class SimpleService is being generated in, then add a using statement in your code to reference that namespace.

Categories

Resources