Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help [C#] WebClient how to know real url [solved]
#11
Oh my lord, assuming you have the URL (or URI) stored somewhere.

Code:
var originalUrl = new Uri("http://example.org/454/history");
var relativePath = "images/hello.png";
var imgUrl = originalUrll.GetLeftPart(UriPartial.Authority) + "/" + relativePath;

Or you can use these convenient functions:
Code:
// GetAbsoluteUrlFromRelative("http://example.org/454/history", "images/hello.png");

private static string GetAbsoluteUrlFromRelative(Uri uri, string relativePath)
{
    return uri.GetLeftPart(UriPartial.Authority) + "/" + relativePath;
}

private static string GetAbsoluteUrlFromRelative(string url, string relativePath)
{
    return GetAbsolutePathFromRelative(new Uri(url));
}
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.

#12
Thx you for the answers, i'll check it tonight when i'll be at home!

@SailorMoon thx for link for downloadsvn, but my script to get the images url works well, i just need a way to get the images download url with combining the page url woith the image relative path. I don't need to php file or other scripts, just the images.
@archit thx, but i think your solution do not work properly with rewrited url as in my example.
@master131 thx for your code, i'll try it tonight, it seeems to be what i need... Wink

Thank you very much all, i'll give feedback tonight! Thx again!

#13
@SailorMoon the script on codeplex is nice, but if i read correctly the code, it didn't take care of rewriting urls because its made for svn and gits links that doesn't use it.

@master131 @archit
With this url "http://example.com/section1/theExecutedScript/Arg1/Arg2"
and this image path "images/test.png"

@archit solution gave me "http://example.com/section1/theExecutedScript/Arg1/images/test.png"
@master131 solution gave me "http://example.com/images/test.png"
but in this case i need to get "http://example.com/section1/images/test.png" because section1 is a folder, theExecutedScript is the executed script, so the relative path "images/test.png" should start from there...

I thought there was a way to get the current executed script path like in php with $_SERVER['SCRIPT_NAME'] that should give "/section1/theExecutedScript.php", and with that we can find "/section1/images/test.png" then "http://example.com/section1/images/test.png".

Firefox can show us the images, so with the page url and the image path, we should be able to find the image absolute path...

#14
@narkos Aren't arguments given like "http://example.com/section1/theExecutedScript?arg1=a&arg2=b" ?

#15
(09-03-2013, 11:02)archit Wrote: @narkos Aren't arguments given like "http://example.com/section1/theExecutedScript?arg1=a&arg2=b" ?

Yep when the url is not rewriten...
But you're right, it depends on the way they rewrite the url.

But for example, with this url/page: (this url exists)
http://www.pcgamer.com/2012/10/28/the-25...im-mods-2/

In this url the / are used to separate args, not as folder... that's why it's hard to retrive the real adress.

But if i'm wrong with how url rewriting works please correct me.

*********************
I have at least 1 solution, but very poor solution.

1. I take the full page url, add the relative image url and check if it exists.
2. If not, i take off the last "/args" and try again if it exists...
3. Do step 2 until it found an image.

It is very very poor because for each image it will check every combined path until it found an image (and maybe not the good one...)

Thx again for the time you take to help me!

#16
I couldn't find any image with a relative URL on that page

#17
I just give the url as an example of a rewrited url that uses / to separate args...
I don't have a good url to show you at this time, because i'm at work, but i'll search tonight to find a complete example.

#18
Quote:Typical @Arteq retardness. We DO NOT NEED STUPID RETARD MODERATORS LIKE THIS ONE.

Quote:This answer is pretty retarded. Did you even read the thread?

You guys are retarded, or you simply can't read. I am quoting myself "never met relative paths to something, I always get full paths". This means when I want to get URL of a picture or something I always get full path to it, not the "images/pr0n.jpg" shortened one. So I read the thread. Better take time trying to understand what one said than jump in crying how retarded he is whilst it is just you who can't read.

Also sailer can you stfu already? I do not have time for modeation. Nova is not adding any new mods. You just did not understand my post and made yourself look retarded, I am OK. And finally, even if I actually wrote something that did not make sense (which I didn't do)
a.) This is a coding thread and I am not a coder. Moderating != knowing all programming languages and being 1337 coder
b.) you urself sailer make retarded comments that do not make sense MUCH more often than me.
[Image: r212360a129ce9b84444093b6cd2699013a1fbn155.png]

#19
Hello,

Here is a website i found for the example: (sorry, it's in french)
http://www.elysee.ch/la-nuit-des-images/edition-2012/

On this page, we can see an image with an old women in the center of the screen.
here is the relative url of the image: "typo3temp/pics/3fc182c820.jpg"

I got the absolute path of the image with a right clic of the browser... etc: "http://www.elysee.ch/typo3temp/pics/3fc182c820.jpg"

How can i get this absolute path with "http://www.elysee.ch/la-nuit-des-images/edition-2012/" and "typo3temp/pics/3fc182c820.jpg"?

If i'm right, with this 2 elements, we can make 3 options:
http://www.elysee.ch/la-nuit-des-images/...82c820.jpg
http://www.elysee.ch/la-nuit-des-images/...82c820.jpg
http://www.elysee.ch/typo3temp/pics/3fc182c820.jpg

How can i know the good one? (without testing each combination)

Thank you!

#20
(09-05-2013, 18:27)narkos Wrote: Hello,

Here is a website i found for the example: (sorry, it's in french)
http://www.elysee.ch/la-nuit-des-images/edition-2012/

On this page, we can see an image with an old women in the center of the screen.
here is the relative url of the image: "typo3temp/pics/3fc182c820.jpg"

I got the absolute path of the image with a right clic of the browser... etc: "http://www.elysee.ch/typo3temp/pics/3fc182c820.jpg"

How can i get this absolute path with "http://www.elysee.ch/la-nuit-des-images/edition-2012/" and "typo3temp/pics/3fc182c820.jpg"?

If i'm right, with this 2 elements, we can make 3 options:
http://www.elysee.ch/la-nuit-des-images/...82c820.jpg
http://www.elysee.ch/la-nuit-des-images/...82c820.jpg
http://www.elysee.ch/typo3temp/pics/3fc182c820.jpg

How can i know the good one? (without testing each combination)

Thank you!

Search for the basehref in the source(line 16 on that page):
Code:
<base href="http://www.elysee.ch/">

Basehref + relative path image = full image path



Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation [News] The REAL winner of FIFA WC 2014 House 4 4,379 07-30-2014, 18:46
Last Post: SuperNovaAO
  Real party song 4FunPlayin 5 4,769 05-20-2014, 20:15
Last Post: Nekochan
Information Help How to edit new derived entry? (Solved) SSonic70 1 2,493 08-20-2013, 15:29
Last Post: Nekochan
  [Release] Barata's REAL External Console Source C# barata 37 21,126 06-28-2013, 23:47
Last Post: barata
  This is real or fake LazerON 14 9,585 06-07-2013, 16:36
Last Post: DidUknowiPwn
  Preview Barata's REAL External Console barata 10 7,727 02-09-2013, 15:36
Last Post: JariZ
Wink Your real name 99IRock 27 13,443 01-16-2013, 13:50
Last Post: Rendflex
  Help [solved]red hitmark mod? founderlj 7 4,223 12-30-2012, 23:06
Last Post: Pozzuh
  !weapon Plugin help pls [solved] Hallla 0 1,854 12-30-2012, 14:04
Last Post: Hallla
  Help !giveammo Plugin doesnt work [solved] Hallla 3 3,272 12-29-2012, 20:53
Last Post: Hallla

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.