简体   繁体   中英

accessing javascript code using c# and asp.net?

I am working on a small project and i have got a problem.

If i want to get some information from a web page/blog then i can use webclient method and parse the HTML page using HTMLAgilityPack in c#.net It's okay

But this time i want to get the information from Share buttons (ie FB share, Retweet button etc) located along with a blog post. These buttons also contains the information about how much time a post has been shared.(no. given with the button) So i want to access that information.

I know that this is coded with a JavaScript file (mi right ?) and all information is contained within that only.

But i want to access that information...

The implementation is based on what share plugin is used, there are tons of them.

Mostly it's JS yes, writing HTML dynamically by JS "in the browser".

You can try some browser automation / testing framework like Selenium WebDriver to automate the browser opening the page, waiting for a while for JS to do its work, and querying the browser for the values of the elements you expect to be filled by then.

Check http://seleniumhq.org/ , http://nuget.org/List/Packages/Selenium.WebDriver

The obvious drawback though is that the code needs an actual user profile to be running, not work as a service or so. There is no "good" "reliable" browser-less UI testing framework in .NET AFAIK.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM