I am trying to locate a .mp4 file from this following URL programatically.
https://twitter.com/ERA_fm/status/691183877411328001/video/1
when this page is opened in a web browser and when I debug through inspect element I can see the .mp4 file in the <video> tag embedded in an iframe.
Now I have written this code to download the url which is as follows:
string siteUrl = "https://twitter.com/ERA_fm/status/691183877411328001/video/1";
string html = new System.Net.WebClient().DownloadString(siteUrl);
I see the downloaded source does not contain any video element associated with it, rather there is no iframe element at all.
Related
I have this image URL i got from database.
\\Imagepath\ImageFolder\image.png
but i need to put in a img tag in html to show the image in the page, i try to do this way
<img src='\\Imagepath\ImageFolder\image.png'/>
but the page adds the default url for localhost, ie.
http://localhost:1234/\\Imagepath\ImageFolder\image.png
I need your helpfor trying to get the image from that server URL.
I have a lot of images around 6,200 so is not an option to download, i'm show the images in a table.
NOTE: i know the img tag not accept the URL like i have, but maybe you have an idea to do in ASP.NET, i apretiate your help.
NOTE 2:i'm using ASP.NET MVC.
Paths starting with \\ are UNC paths, they are not URLs. In a browser, you have to use a URL to load an image.
The browser is assuming you've tried to specify a relative URL, and is attempting to add the current URL by default in order to fully qualify it and then make a request to it to get the image.
You need to map the path to a virtual directory in your webserver and then point the image's src property at the URL of that virtual directory.
Alternatively, if that's not a workable solution you could write an MVC action method which takes the name of the image file as a parameter and then loads the image from the UNC path in the background and returns the data in a binary response to the browser.
I need to use C# Console Application.
I have a web Page URL
Inside the web page there is a button that downloads file by click
In View Source of the web page ,the button looks like this:
<a class="A" href="/myfiles/myfile.csv" target="_blank">הורד קובץ</a>
I should get the csv file in code by the URL.
How can I do it?
my question is similiar to this one , but not the same load a web page and click a button using c# I didnt find an answer yet.
Use WebClient class to download the HTML. Parse it manually to pick out the href. Use the WebClient class again to make a call to the href target. This should cause the file content to be downloaded as a response to your HTTP request.
I'm using the webbrowser control to scrape my medical information from my Health Care provider,
The website is secured using a username and password, I've managed to scrape everything I need except some pdf file.
After navigating to the page I get this javascript "Loading...", In a regular browser I'll see the PDF file rendered in the browser, but for the webbrowser control it doesn't display the pdf, I get the famous yellow notification bar.
The url for the pdf file is like this
"https://www.***.com/phoenix/views/akgCharts/zoomAkgChart.jsp?&date=20130502&time=123000",
I'm using mshtml to do all the scraping, I don'tfind the file in the mshtml object, using fidller 2.0 I can see that the pdf file is downloaded to the computer (somewhere in the memory, I didn't find it in any folder)
Any idea??
if you know the url what is sends you the file you can try something like this:
System.Net.WebClient _wclient = new System.Net.WebClient();
_wclient.DownloadFile("https://www.***.com/phoenix/views/akgCharts/zoomAkgChart.jsp?&date=20130502&time=123000",", #"c:\MedicalReport_" + DateTime.Now + ".pdf");
I need to open up Internet Explorer with an URL and then read the source code of the document in C#.
Is this possible?
I know you can start processes but how can i navigate to an URL and get the source code?
I have to open it via IE, because the protocol im using to retrieve the page only works in IE.
Thanks!
Following can get you html from a url without opening IE.
using(WebClient client = new WebClient()) {
string html = client.DownloadString(address);
}
To open IE for a particular URL you can do :
System.Diagnostics.Process.Start("iexplore", "http://example.com");
Depending on your requirements there are different techniques:
Process.Start("iexplore.exe", "http://www.google.com"); to run IE and then a WebCilent.DownloadString to download the HTML source (2 HTTP requests sent to the server)
Use the WebBrowser control which allows you to embed IE in a desktop application. It also allows you to retrieve the HTML source code of the webpage to which it navigated.
I have a WebBrowser element in my UI, I can make it navigate to a hosted page, but when I want it to load a local webpage (which is in my solution resources), which is the exact html file hosted on internet, it just shows a blank page.
browser.Navigate(new Uri("test.html", UriKind.Relative));
If I change the UriKind or the page name it shows an error that the file could not be found, so I know the browser is finding the webpage correctly but it won't render it.
I need to do this because I want to show the page while the user is offline.
If the html file has a build action of Content you can access it directly from the install location if you set a relative path.
If you want to be able to navigate between pages or include other resources in the file (including external css, js or even images) then you'll either need to copy all the files to IsolatedStorage and view them from there or host them externally.
Edit:
MSDN has an article which explains copying files to IsolatedStorage, so they can be viewed in the WebBrowser control, at http://msdn.microsoft.com/en-us/library/ff431811(v=vs.92).aspx
The browser cannot read a resource from your App/Dll. However, it you have the file in the same folder as you application you could do:
var home = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
browser.Navigate(new Uri("file://" + home + "/test.html");