anglesharp

How can I change a tag name in AngleSharp?

风流意气都作罢 提交于 2021-02-11 08:39:31
问题 Is it possible to change the name of a tag from code? Something like this: var tag = doc.QuerySelector("i"); tag.TagName = "em"; This won't work, because TagName is read-only. But, what are my options for getting to the same end? Would I have to construct an entirely new tag and set the InnerHtml to the contents of the old tag, then delete and swap? Is this even possible? 回答1: If you mean to replace the elements in html string then it can be done this way: private static string

How is it possible to remove all rows from the HTML table using anglesharp?

╄→尐↘猪︶ㄣ 提交于 2020-01-28 11:38:11
问题 How is it possible to remove all rows from the HTML table using anglesharp? I am trying to remove all rows in table. I've read this documentation, however, rows are not removed. My code looks like this: public void DeleteRows(IElement table) { foreach (var row in table?.QuerySelectorAll("tr")) { row.Remove(); } var lengthAfterDeletion = table?.QuerySelectorAll("tr")?.Length; } How is it possible to remove all rows from the HTML table using anglesharp? 回答1: I think we figured it out in the

Getting Href property with anglesharp linq query

谁说我不能喝 提交于 2019-12-24 13:24:27
问题 I am trying to understand how to use anglesharp. I made this code based on the example (https://github.com/AngleSharp/AngleSharp): // Setup the configuration to support document loading var config = Configuration.Default.WithDefaultLoader(); // Load the names of all The Big Bang Theory episodes from Wikipedia var address = "http://store.scramblestuff.com/"; // Asynchronously get the document in a new context using the configuration var document = await BrowsingContext.New(config).OpenAsync

Get and Download pictures with AngleSharp

被刻印的时光 ゝ 提交于 2019-12-24 12:34:52
问题 I started using Anglesharp for a Project, I need to get and download not only HTML but also images of the document. I know that in the Document object there is a property called Images, but appearently it doesn't get all of them, I did a test on a YouTube page and got only one (repeated several times). For example I'd like to get the thumbinail of the current video, and this seems to be inside a <meta> tag. To be more precise, images are stored inside this kind of tags: <meta content="https:/