Download File From Website with URL Authentifikation C# - c#

I am trying to download a file from one of this sites:
1cloudfile
bowfiles
games-database
Mainly games-database.com
I think all of this sites are using a similar System
For example games-database.com:
An example link: https://games-database.com/1JD4
There is one button on this website that opens a new window with a link
<button style="margin-bottom: 30px;" class="btn btn--primary type--uppercase" onclick="window.location = 'https://games-database.com/1JD4?pt=ZUVGTGRtaExNa3hIYkdJMllrcHZkbkJ6TjBGU1p6MDlPbWFXZ3IrNnZDMzI1MnZzVlVJU2hKQT0%3D'; return false;">download</button>
Link: https://games-database.com/1JD4?pt=ZUVGTGRtaExNa3hIYkdJMllrcHZkbkJ6TjBGU1p6MDlPbWFXZ3IrNnZDMzI1MnZzVlVJU2hKQT0%3D
This link is different everytime I refresh the page
It's easy to get this link with HTMLAgility Pack
using HtmlAgilityPack;
var link = doc.DocumentNode.SelectNodes("/html/body/div[2]/section/div/div/div/div[3]/div[2]/button")
.Select(p => p.InnerText).FirstOrDefault();
But when I try to download this I only get the page not the file
The working generated download link after the redirect looks like this:
https://dl5.cdnrobot.xyz/1JD4/Anomic_THE_NEW_GUI.txt?download_token=f58c9315280ed7474c15a329888ac8532e2af1cdaec045f4048bc51fcacd7e75
I don't know if the sites uses cookies or something else but maybe you can load the page in the background and then get the download link by tracking the redirects.
Thanks for everyone who wants to help!
I am on WPF .NET 6.0 btw
[EDIT]
I found a website called https://wheregoes.com and it manages to track the correct download URL
Then it tell me:
Status Code: 200 - Meta-Refresh Redirect
In conclusion I need a way to trace this redirect to get the download URL

Related

Is it possible to open the html page from the silverlight application with the choice of browser?

Is it possible to open an html page from silverlight web application in chrome/firefox ?
Issue is I have 3 broswers installed on my windows pc.
1.IE
2.Chrome
3.Firefox
I would like to open the html page from silverlight web application in Chrome and not in IE.
I am using following code to open the page.
HtmlPage.Window.Navigate(new Uri("Google.com")); // Opens in IE. But I want it to open in Chrome.
Thanks.
I think you can try this approach ..
From silverlight start the process ( the browser you want to open .. here the challenge would be you need to the path where browser is installed. )
Mostly all browsers support command line arguments ( url is one of them )
you may need to combine these both to achieve your requirement.
for step one as example how to start a process you can refer this link #1
for step 2 you can refer this link #2 example mozilla
Use below code to open .html page from silverlight application.
HtmlPage.Window.Navigate(new Uri(Application URL + "../index.html"), "_blank");

Execute function from a webpage that is activated onclick

I have to make a console application in C# which retrieve some data from webpages.
I have downloaded the HTML code from the main page of a website.
WebClient client = new WebClient();
String htmlCode= client.DownloadString(linkToWebpage);
I have verified the string and it is good.
After this part, I have searched for a specific line in the html code which contains a button and a link.
<a rel="nofollow" class="link" onclick="loadornot()" href="http://aaaaa.com/D?WUrtlC1" target="_blank">Click to read more</a>
Now i am trying to download html code from the ancored link (the one from the href), but I am redirected to the main page and I am not sure why. Even if I copy the link from href and paste it into a webbrowser, I am redirected to the main page.
I believe that this happens because the button call a function onclick="loadornot()". That's why it doesn't work the way I have tried? And if yes, how could I call that function from my c# application to continue my app?
Thank you.
Edit:
I have found out that I need some cookies, more exactly, sessioncode, to make that link work. How can I do that?
You can't run javascript code from web page without browser. So, if you really need to execute that function in downloaded page, use some kind of headless browser, like those: webkitdotnet or awesomium

issue with child application paths

I created a new website in IIS called wbsite1. Then I added an application to website1 wich is a website called website2. The problem appeared when we tried to access links in website2. The browser always refers to the root url and redirect so we were trying to change all the urls in website2. For example, if we have a url in website2 like :
<a href='http://localhost:2030/website2/cms/default.aspx...'
and we click on that link the browser redirect us to :
http://localhost:2030/website1/default.aspx
Why am I getting this behavior? And what is the best workaround to integrate two websites without trying to mess with every link in the website? Thank you very much.
We are facing troubles when I try to access a page in the child application it redirects to the default page of the main application and gives the error:
Session state is not available in this context.
I found the solution for my question and it's this :
unfortunately i have to "rewrite" all our links in my code.
so i created a function which will automatically add prefix to external links,
and store base link for other site it configuration.
I did such project with success. thank u for all your replies
i found another solution also and it's using a web proxy but i can't use it in my scenario

How to Add google doc viewer in mvc4 Applicaton?

I am beginner in programming. My problem is, I want to show PDF files in Google Doc Viewer in my website page. I put my PDF files in folder named as Bullettin, it is in App_Data folder.
How can I view this PDF file in my website through Google Doc Viewer using C# MVC4 application?
i used the following code in view page
http://docs.google.com/viewer?url=http://localhost:3907/App_Data/Bullettin/JCI.pdf&embedded=true" target="_blank" class="embed">View
You should use the following url for embed: http://docs.google.com/viewer?url=http://localhost:3907/App_Data/Bullettin/JCI.pdf for previews
and: Preview
for links, and finally:
<iframe src="http://docs.google.com/viewer?url=http://localhost:3907/App_Data/Bullettin/JCI.pdf&embedded=true"></iframe>
For Iframes.
Well, localhost will not work for you, so get your project on a live server or use an IP address to link your server.
Good luck with it.

How to allow cookies in windows 8 c# app or click a html button via c# code

I have a web page with this part of code:
<form action="/?cid=2000" id="queryForm">
<div><button type="submit" name="computeTrip" value="true" class="button">compute trip </button></div></form>
I need to run this in my c# app. I tried a POST method but it doesnt work. (I think I could do it wrong).
To achive next page I wanted to download code in first page,to make changes in http adress and next run second page. But I have to alllow cookies.
I use Http Client sample from msdn.
Thanks for help!

Categories

Resources