Hello, the following script retrieves all URLs and titles from the blog’s feeds. If you want to display all the URLs and titles on your website, you can obtain the information from the script below

If you want to gather links and content from various feeds on the web, PHP can be a powerful tool. This article will guide you through the process of extracting links from feeds using PHP. Whether you’re looking to aggregate news, blog posts, or other data sources, this technique allows you to efficiently access and utilize the valuable web content available. Get ready to expand your web content with this essential skill.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
function getlinks() {

$xml= "https://www.anillabs.com/feed/";

$xmlDoc = new DOMDocument();

$xmlDoc->load($xml);

//get elements from "<channel>"

$channel=$xmlDoc->getElementsByTagName('channel')->item(0);

$channel_title = $channel->getElementsByTagName('title')

->item(0)->childNodes->item(0)->nodeValue;

$channel_link = $channel->getElementsByTagName('link')

->item(0)->childNodes->item(0)->nodeValue;

$channel_desc = $channel->getElementsByTagName('description')

->item(0)->childNodes->item(0)->nodeValue;

$result='';

//get and output "<item>" elements

$x=$xmlDoc->getElementsByTagName('item');

for ($i=0; $i<=7; $i++)

{

$item_title=$x->item($i)->getElementsByTagName('title')

->item(0)->childNodes->item(0)->nodeValue;

$item_link=$x->item($i)->getElementsByTagName('link')

->item(0)->childNodes->item(0)->nodeValue;

$item_desc=$x->item($i)->getElementsByTagName('description')

->item(0)->childNodes->item(0)->nodeValue;

$result .= ("<p><a target="_blank" href='" . $item_link

. "'>" . $item_title . "</a>");

$result .= ("<br />");

$result .= ("</p>");

}

return $result;

}
?>

We can see the live demo at  @ http://labs.anillabs.com/

In conclusion, mastering the art of extracting links from feeds using PHP can open doors to a wealth of valuable web content. Whether you’re building an aggregator, automating content curation, or simply seeking to access external data sources, this skill is indispensable. With the knowledge gained from this article, you’ll be well-equipped to create dynamic web applications and stay up-to-date with the latest information from various online sources. Start harnessing the power of PHP for feed-based content extraction today.

Categories: PHP Code

4 Comments

Srinivas Tamada · December 24, 2009 at 6:02 am

useful .. post this on Developer zone http://dzone.com at right category

How to get links from feed using php « ANIL KUMAR PANIGRAHI 's Blog | Coder Online · December 24, 2009 at 6:13 am

[…] Excerpt from: How to get links from feed using php « ANIL KUMAR PANIGRAHI 's Blog […]

how to convert feeds to html using javascript and php - ANIL KUMAR PANIGRAHI 's Blog · September 16, 2011 at 3:08 am

[…] In have created this post with using my previous posts. 1) How to get links from feed using php http://www.anil2u.info/2009/12/how-to-get-links-from-feed-using-php/ 2) How to clean a string using php code […]

Mobile web app using with your RSS feed and PHP - Anil Labs · November 1, 2023 at 3:40 pm

[…] You can create a simple mobile web application using your blog’s RSS feeds. In my previous post, I explained how to fetch RSS feeds using PHP. […]

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *