internet search and %20

iankerry

Registered User.
Local time
Today, 02:40
Joined
Aug 10, 2005
Messages
190
Hi

I have a button on my form which when pressed goes to imdb.com and does a search for the film name that is on the record. This used to work but now I get a %20 instead of spaces when I arrive at the imdb site. (127%20Hours instead of 127 hours)

I think I have to use underscore in the film name to make it work again?

Code:
Dim imdb
Dim searchterm
imdb = "http://imdb.com/find?q="
searchterm = imdb & filmtitle.Value
Application.FollowHyperlink searchterm

If this is the only option, how can i turn any spaces into underscores? Or any other ideas gratefully accepted!

Ian
 
I typed http://www.imdb.com/find?q=127 hours on the url line of the browser and it worked, but it gave me several choices. Spaces are normally converted to %20 in this kind of thing.
Stop the code in debug on the followhyperlink and look at searchterm. Copy and paste it into browser and see if it works.
 
Hi James

Most interesting. When I clicked your link it worked - but on mine i get the %20 in the imdb search box. But ONLY on IMDB, in other search engines it works ok.

My search term has spaces in it = "http://imdb.com/find?q=127 Hours"

So it seems I need to get a %20 instead of the spaces in the film title? But this seems a weird thing to try and have to do - or is there something else going on that I am missing, James?

Thanks
 
Last edited:
Anyone any ideas? Have been looking around the internet but can't seem to find an answer that works.

Thanks

Ian
 
no expert, but I assumed %20 was just internet speak for a space

space is chr(32), which is Hex20.


does the search yield anything, or nothing?


I would dim as string, and maybe send trim(variablename)
dimming as you are makes the variable a variant rather than a string, which may or may not be important

[edit - just tried it

got this reply

No results found for "127%20Hours"

the ie title bar showed this - I do not know where the extra "25" came from.

http://www.imdb.com/find?q=127%20Hours
 
Last edited:
result. I got it to work with this

searchterm = imdb & "127+Hours&s=all"

Code:
 Sub testweb()
Dim imdb As String
Dim searchterm As String
 imdb = "[URL]http://imdb.com/find?q[/URL]="
searchterm = imdb & "[COLOR=red]127+Hours&s=all[/COLOR]"
 Application.FollowHyperlink Trim(searchterm)
End Sub


possibly replace spaces with +characters and add the "&s=all".
 
Thanks Jemma, that does indeed work.

Not sure why this is only a problem on IMDB as all the other buttons work for searching amazon and google etc.

I just need to research how to make spaces into +'s now. but thanks for your help, you have got me on my way!

I.
 
mystring = replace(mystring,"__"," ") 'replace double spaces with single - may or may not be needed - you need two spaces in the first expression, not underscores- I had spaces, but the site changed it a single space!
mystring = replace(mystring," ","+")
 
Perfect Dave, thanks very much.

And sorry for calling you after your dog.

Best regards
Ian
 
no probs. that's my user name.

by the way - the code itself was interesting. followhyperlink is deceptively powerful, isn't it.
 

Users who are viewing this thread

Back
Top Bottom