Get info from current webpage in Chrome - c#

I am member of a website and want to grab some info from the current open window in Chrome. That is, if I am looking a persons profile in Chrome, I want my C# program to be able to get the source code of that website so I can retrieve birthday, location, etc from it. Is there a way to do this?
I guess a solution is to incorporate the webbrowser control in a winforms project and use that instead of chrome. but it would be nicer if I could just use Chrome as I normally do and then when I switch to my C# program it copies the source code and parses whatever info in it that I find relevant.

You can try to use the C# version of Selenium for automating your browser. It's mainly designed for testing, but it should help you solving your problem. It comes with a driver for Google Chrome.

Related

C# Get element in chrome browser WITHOUT Selenium. Just pure C# code

Is there a easy way to get a element from chrome without using Selenium? Just pure C# code
I was thinking to somehow get the current tab HTML source code and get all the element values that way. Does anybody have any idea how to do this? And it needs to be a already active browser. So i can't use any HTTP request
You're looking for a C# interface to the Chrome DevTools Protocol. There is such a thing, unsurprisingly called ChromeDevTools. The included sample shows you some DOM navigation code.

Targeting a specific Chrome process?

When I open the Chrome's Task Manager, I can see something like this?
Now, programatically, is it somehow possible to target the Chrome instance that is being used to run the Flash Plug-In? Maybe using System.Diagnostics.Process class or native API calls?
I was able to do this with native api calls. My solution worked perfectly on my machine. Here is what I did:
First, get Microsoft Process Explorer. Using this tool, I was able to get the flash plugin dll's name that chrome uses which is called pepflashplayer.dll in my case.
Next, a little search on Bing got me this article. It's C code so I converted to C# and after some coding I was able to retrieve the correct Chrome process ID that uses flash plug-in.
I have uploaded my solution to SkyDrive for you to check here. Note that I am not closing any handles in my sample so you'll have to add that for a real project.
There might be better solutions out there but this one should work. Hope it helps.

How to give Csharp Webbrowser default Path to download files

I am making a web browser in C Sharp, I want that all the files downloaded by the user on this web browser from any web sites, web browser saves it in one default folder (i.e C:\Users\Abc\Downloads)
Currently when i try to download file from any url it pops up a dialogue box asking for path, and it is annoying thing to have so i just wants to give one default path where it just saves the file automatically without asking user for the path.
Like we have default download path for Mozila firefox and google whenever user download any file from the web browser it saves in one default folder. so how can I achieve this in .net 4.0 Csharp web browser.
I'm afraid you can't with the webbrowser control,
maybe take a look at
http://www.mono-project.com/WebBrowser
first you don't use IE, and you can do more if I'm right
Regards,
Corné
If you're using the WebBrowser control in c# this can be somewhat of a challenge, but have a look at this link which might help you, I've tried it myself with good results.
http://www.codeproject.com/Articles/31163/Suppressing-Hosted-WebBrowser-Control-Dialogs
Good Luck! :)
Edit:
You might want to look into this solution to your issue as well:
Automated filedownload using WebBrowser without url
:)

Open URL in browser and take image snapshot in an automated fashion

I was wondering if there was any way we could programmatically fire up an URL in a browser (i.e. firefox or google chrome), and take a snapshot of the webpage.
It would be awesome if this can be done in Linux environment. I do not have any lead on how to go about it; I can going to mark this in C# too - I'm willing to settle for Windows based approach also
I think wkhtmltopdf will pretty much do what you're looking for. It uses WebKit, the Chrome/Safari engine)
the wkhtmltoimage executable will take a URL and file save location arguments.
Windows/Linux/MacOS flavors.

scraping/simulate browsing help

I want to make a program that will simulate a user browsing a site and clicking on links. Cookies and javascript have to be enabled. I've successfully done this in python, but I want to write it an compilable language (python ide's don't cut it). The links on the site are generated with javascript and are dynamic. With python I used PAMIE (third party module that uses win32com) to launch an instance of Internet explorer, scrape the generated html for the links, then navigate to one of them. The point is for the whole process to be transparent to the server. What's the best (compilable) language and method to do this? I was thinking C# with WebBrowser control but I don't want to spend a lot of time learning something if it isn't going to work. Any kind help is appreciated!
You might want to look at the automated testing via browser suites:
http://www.teknologika.com/blog/the-holy-grail-net-automated-web-gui-testing-for-internet-explorer/
http://watin.sourceforge.net/
I wrote a blog post on this awhile back: Web scraping in .NET. That discusses cookies but not JavaScript; I don't know if that would require additional coding.
Might be worth having a look at selenium .
We use it for web testing in a C# asp.net envirnorment.
The documentation isn't to bad

Categories