C# web scraping with HtmlAgilityPack [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want to create application in WPF wchich will scrape information from webpage
I read link to the page from text box at the top
I want to extract company name from h6
I don't understand that format:"//h2[#class='card__title mdc-typography--headline6']". I could't find documentation abot meaning # [] etc. to create another filters to scrape other data for example phone number from tag.

The #, //, ... represent abbreviated syntax for XPath selectors.
#abc is short for attribute::abc
// is short for /descendant-or-self::node()/
So, in other terms, your current query //h2[#class='card__title mdc-typography--headline6'] represents the action of finding the first descendant- or self-node that has a class attribute of card__title mdc-typography--headline6.

Related

Counting frequency of characters in a line from a .txt file [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a C# task to do and I am stuck on part of the coding. I am using StreamReader to read a .txt file which contains group exam grade data (e.g. ADCBCBBBADEBCCBADBAACDCCBEDCBACCFEABBCBBBCCEAABCBB), I need the code to work out how many A's, B's etc there are inside each set of data, I thought about using some form of count++ code but each attempt just throws errors.
I want it to print onto console the number of A's in that line of the .txt file.
I hope that makes sense, I understand how to do the rest but I just needed a hand on this section.
Consider using System.Linq, eg...
string myString = "ADCBCBBBADEBCCBADBAACDCCBEDCBACCFEABBCBBBCCEAABCBB";
int countOfAs = myString.Count(x => x == 'A');
//Result: 9

scanning a portion of webapage using htmlagilitypack and C# [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to scan a portion of the webpage for specific URLs using htmlagilitypack and C#. How can I do it? For example I would like to scan only the links of the ads from this page http://www.olx.in/mobile-phones-cat-831 and not all the links.
It looks like each of the Add links is nested inside a div with a specific class (adListDetails), so one can look for any links inside a div with said class. That would look like this:
var nodes = document.DocumentNode.SelectNodes("//div[class='#adListDetails']//a[#src]");
foreach (var node in nodes)
{
string src = node.Attributes["src"].Value;
}
Learn more XPath from a source like w3schools.

C# webBrowser1.Document - find all elements by class attribute [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm using webBrowser control in winform app C# FW4.0, and I would like to find all the elements that their class attribute contains some value. Is it possible?
You can do this, but it will take some work on your own.
An example on how to find all a tags with class show1 should help you find what you need. Here is an excerpt from the example there
var links = webBrowser1.Document.GetElementsByTagName("a");
foreach (HtmlElement link in links)
{
if (link.GetAttribute("class") == "show1")
{
//do something
}
}

Is the any restriction in using currently present Image property? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to write some property item to image. Though I could not do it. But I can edit any currently added property. So I want to know is there are any property item I can use for my purpose? Here are some Id I am getting:
Id:271
type 2
Id:272
type:2
Id:274
type:3
Id:282
type:5
Id:283
type:5
Id:296
type:3
Id:306
type:2
....
etc.
My question is can I use any of the currently present property?
Sounds simple i think
<img id="myimage" data-id="data you want to pass"/>
if you want to add attribute from c# then
ddLedger.Attributes.Add('data-id','yourvalue');
So you want to access this property at backend c# then
string aa=myimage.attributes("data-id");
in string aa you will get your data....
and in jquery
$('#myimage').attr('data-id');
Now if you want to add it at run time then like this
$('#myimage').attr('data-id','your id added');
Demo
Check this url for more details
https://stackoverflow.com/a/1735239/2630817
I hope this will help you....:)

C# one-liner to grab specific data from an RSS feed [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm looking for a C# "one-liner" (need not strictly be a single line, but very short is preferable) way to download an RSS feed from a given HTTP URL, and extract specific data. Robustness be damned. Something that doesn't require any external libraries.
Specifically I want to count the number of <item>s in the RSS. But some kind of LINQ method that could be reused to, say for example, return a list of the item <title> elements would be most useful, if it can be kept short.
Regex.Matches(new WebClient().DownloadString("http://stackoverflow.com/feeds/question/7180063"), "<entry>").Count
What about something like this:
var rssFeed = XDocument.Load("http://weblogs.asp.net/scottgu/rss.aspx");
var posts = from item in rssFeed.Descendants("item")
select new
{
Title = (string)item.Element("title"),
Published = (DateTime?)item.Element("pubDate"),
Url = (string)item.Element("link"),
};
Source.
SyndicationFeed.Load(XmlReader.Create("http://weblogs.asp.net/scottgu/rss.aspx")).Items.Count();

Categories

Resources