dinubs / jam-api

Parse web pages using CSS query selectors

Home Page:http://www.jamapi.xyz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

C# options

jhallam3 opened this issue · comments

Hi,
Was wonder how I can use this within my c# application.

Hopefully there is an option..

Hey @jhallam3, I've never written C# before, but it does look like it's possible to use the service from inside of the language. Here's an example of how it would work.

using System;
using System.Net;
using System.Collections.Specialized;

public class Program
{
  public static void Main()
  {
    var wb = new WebClient();
    var data = new NameValueCollection();
    data["url"] = "http://www.radcircle.com";
    data["json_data"] = "{'title': 'title','logo': '.nav-logo img'}";

    var response = wb.UploadValues("http://www.jamapi.xyz", "POST", data);
    var result = System.Text.Encoding.UTF8.GetString(response);
    Console.WriteLine(result);
  }
}

If this works for you, please close the issue and I'll add this example to the ones that are already on the site.

So I would call the JAMapi URL rather than have the service within my code…

Is the service something I can have installed or do I always call the service from your URL ?

Thanks for getting back to me.

On 9 May 2016, at 17:08, Gavin Dinubilo notifications@github.com wrote:

Hey @jhallam3 https://github.com/jhallam3, I've never written C# before, but it does look like it's possible to use the service from inside of the language. Here's an example of how it would work.

using System;
using System.Net;
using System.Collections.Specialized;

public class Program
{
public static void Main()
{
var wb = new WebClient();
var data = new NameValueCollection();
data["url"] = "http://www.radcircle.com";
data["json_data"] = "{'title': 'title','logo': '.nav-logo img'}";

var response = wb.UploadValues("http://www.jamapi.xyz", "POST", data);
var result = System.Text.Encoding.UTF8.GetString(response);
Console.WriteLine(result);

}
}
If this works for you, please close the issue and I'll add this example to the ones that are already on the site.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub #12 (comment)

You can install and run the service on your own machine, just need to have node v4.2.2+ installed.

To do so you'd do the following:

git clone https://github.com/gavindinubilo/jam-api

cd jam-api

npm install

node index or you can use a library to run it as a daemon (e.g. https://www.npmjs.com/package/pm2 or https://www.npmjs.com/package/forever).

This will run a local copy of JAMapi at localhost:5000 then you can change any instance of http://www.jamapi.xyz to localhost:5000.

cool thanks man!

Thanks good!

On 9 May 2016, at 17:30, Gavin Dinubilo notifications@github.com wrote:

You can install and run the service on your own machine, just need to have node v4.2.2+ installed.

To do so you'd do the following:

git clone https://github.com/gavindinubilo/jam-api

cd jam-api

npm install

node index or you can use a library to run it as a daemon (e.g. https://www.npmjs.com/package/pm2 https://www.npmjs.com/package/pm2 or https://www.npmjs.com/package/forever https://www.npmjs.com/package/forever).

This will run a local copy of JAMapi at localhost:5000 then you can change any instance of http://www.jamapi.xyz to localhost:5000.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub #12 (comment)

Is there a easy method of getting the css tags/ids?

Regards

Jon Hallam

On 9 May 2016, at 17:08, Gavin Dinubilo notifications@github.com wrote:

Hey @jhallam3 https://github.com/jhallam3, I've never written C# before,
but it does look like it's possible to use the service from inside of the
language. Here's an example of how it would work.

using System;using System.Net http://system.net;using
System.Collections.Specialized;
public class Program
{
public static void Main()
{
var wb = new WebClient();
var data = new NameValueCollection();
data["url"] = "http://www.radcircle.com";
data["json_data"] = "{'title': 'title','logo': '.nav-logo img'}";

var response = wb.UploadValues("http://www.jamapi.xyz", "POST", data);
var result = System.Text.Encoding.UTF8.GetString(response);
Console.WriteLine(result);

}
}

If this works for you, please close the issue and I'll add this example to
the ones that are already on the site.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#12 (comment)

I typically use chrome, and I right click on an element and click "Inspect Element" and that will bring up the developer window with the element that you right clicked selected.

I find jQuery / zepto handy as it is usually around in every page. You can just print all the parents and their classes and/or tags.

// For example, https://www.ultimate-guitar.com/tabs/black_sabbath_tabs.htm
// .ugtab2 only in some elements, other rows don't have anything to identify them

$('.ugtab2').parents().each(function(i,elem) {
  var classes = $(elem).attr('class');
  console.log(i, elem.nodeName, classes);
});

From the log I can pick up this:

{
  "tabs": [{ "elem": ".page-wrap .b  tr td tr td tr.tr a", "value": "text"}]
}

Since there's no more discussion around this issue, I'm gonna go ahead and close it.