MyBB Community Forums

Full Version: Mass Creating Hyperlinks
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a list of about 1000 links right now that I need to turn into hyperlinks with the page titles.

For example,

I want to be able to enter http://www.google.com and it creates this hyperlink:

<a href="http://www.google.com">Google</a>

Does anyone know how to generate these hyperlinks in bulk so that it will get the page title and generate the HTML code for me?
You could most likely do this with a simple loop in PHP. The only part I'm not sure about is getting the page title. You'd have to look that part up, or get someone to help you.
Well I know you can just copy the links into Notepad and use the Find and Replace tool like:

Find: http://*.com
Replace: <a href="http://*.com"></a>

And you'd need to enter the name of the link yourself.
An easy way to retrieve the title of a page is to get the contents of the source of the link, and run a match against the title tags, and from there, grab it's contents. I'm sure there are PHP code snippets to do this over the web, just Google it if you don't know how to put the code together yourself. But to save on resources, just grab the first 20 or so lines of the source of each page, there's no need to retrieve all of its contents.

Best Regards,
Imad Jomaa.
(2011-06-15, 05:59 PM)Zash Wrote: [ -> ]Well I know you can just copy the links into Notepad and use the Find and Replace tool like:

Find: http://*.com
Replace: <a href="http://*.com"></a>

And you'd need to enter the name of the link yourself.

Some softwares like vBulletin are able to get that information automatically. Changing it the being a link in NotePad is easy, I'm just trying to figure out how to mass get the URLs.
(2011-06-15, 06:03 PM)Imad Jomaa Wrote: [ -> ]An easy way to retrieve the title of a page is to get the contents of the source of the link, and run a match against the title tags, and from there, grab it's contents. I'm sure there are PHP code snippets to do this over the web, just Google it if you don't know how to put the code together yourself. But to save on resources, just grab the first 20 or so lines of the source of each page, there's no need to retrieve all of its contents.

Best Regards,
Imad Jomaa.

That's how I'd do it too. I was once thinking of writing a simple plugin to automatically do this with plain links as it helps with SEO. I might still do so after my exams.