Ok I'm using Horstl's code, it works pretty fine except for two things:
1. If the URL points to a redirected page, the socket doesn't follow the redirect and instead returns a 301 or 302 response.
2. The regex string isn't recognizing domains such as co.uk
EDIT: Turns out it's linefeeds causing this problem, the co.uk part is probably fine. So if a page looks like:
<title>
Page Title
</title>
It's not recognizing it. Anyone know a workaround?
I've tried replacing linefeeds with whitespace in the returned text but apparently, the response event runs once for every line of HTML returned - so if the titlew tags are on separate lines, there's no way to compare them and get the center, unless a much more complicated setup is used to watch if there's a title on one line, and save each line, and if it finds a </title>, return the last line, etc. etc. etc. I'm hoping there's an easier way around this.
I'm considering setting up another regex and if it finds a redirect, it returns the link and opens a new socket to the new, redirected URL.
Last edited by Tony311; 23/03/09 04:20 AM.