Skip to content

AlexKhranovskiy/praction-rss-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vocation

Praction with php's generators and generators as methods of class.

Description

Project asks the RSS url, choice of method of parsing. There are two methods:

  • With generators
  • Without generators

Project outputs the result of parsing, it is an array of ArrayObject's objects of each items of RSS xml data. Handling starts from reading strings of the remote xml-file. If found , starts read strings while will not be found . In case of method with generators first of all works parse generator, and then itemHandler generator. In case of method without generators when found strings are written to buffer array. In this case script eats more memory as compared with another method. Project outputs the number of bytes was used.

How to run

  • Clone the project.
  • Run:
docker-compose up -d

Some output example:

  • With generators:
Array
(
    [0] => ArrayObject Object
        (
            [storage:ArrayObject:private] => Array
                (
                    [guid] => Array
                        (
                            [value] => 
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [pubDate] => Array
                        (
                            [value] => Tue, 16 Aug 2022 10:18:00 GMT
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [title] => Array
                        (
                            [value] => Monkeypox in kids is rare but infections can be serious
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [link] => Array
                        (
                            [value] => https://www.dw.com/en/monkeypox-in-kids-is-rare-but-infections-can-be-serious/a-62767781?maca=en-rss_en_science-22531-xml-mrss
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [description] => Array
                        (
                            [value] => The number of children who've caught monkeypox is tiny compared to infections among adults. A German child that was believed to be positive did not have the disease, but other countries have reported cases in kids.
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [category] => Array
                        (
                            [value] => Science
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                )

        )

    [1] => ArrayObject Object
        (
            [storage:ArrayObject:private] => Array
                (
                    [guid] => Array
                        (
                            [value] => 
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [pubDate] => Array
                        (
                            [value] => Mon, 15 Aug 2022 12:26:00 GMT
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [title] => Array
                        (
                            [value] => What causes depression? Not low serotonin levels, science says
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [link] => Array
                        (
                            [value] => https://www.dw.com/en/what-causes-depression-not-low-serotonin-levels-science-says/a-62681480?maca=en-rss_en_science-22531-xml-mrss
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [description] => Array
                        (
                            [value] => Low serotonin levels in the brain are commonly thought to cause depression. But science shows the neurotransmitter has little to do with it. What gives?
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [category] => Array
                        (
                            [value] => Science
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                )

        )

    [2] => ArrayObject Object
        (
            [storage:ArrayObject:private] => Array
                (
                    [guid] => Array
                        (
                            [value] => 
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [pubDate] => Array
                        (
                            [value] => Fri, 12 Aug 2022 10:28:00 GMT
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [title] => Array
                        (
                            [value] => China's Langya henipavirus: In a 'scary family' of zoonotic disease
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [link] => Array
                        (
                            [value] => https://www.dw.com/en/china-s-langya-henipavirus-in-a-scary-family-of-zoonotic-disease/a-62780398?maca=en-rss_en_science-22531-xml-mrss
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [description] => Array
                        (
                            [value] => Langya henipavirus is a new zoonotic disease in shrews in China that infected 35 people. Is it worth freaking out? If it starts spreading between people it is.
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [category] => Array
                        (
                            [value] => Science
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                )

        )

    [3] => ArrayObject Object
        (
            [storage:ArrayObject:private] => Array
                (
                    [guid] => Array
                        (
                            [value] => 
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [pubDate] => Array
                        (
                            [value] => Thu, 11 Aug 2022 10:07:00 GMT
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [title] => Array
                        (
                            [value] => Drinking milk 'didn't help' us with lactose intolerance
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [link] => Array
                        (
                            [value] => https://www.dw.com/en/drinking-milk-didn-t-help-us-with-lactose-intolerance/a-62603291?maca=en-rss_en_science-22531-xml-mrss
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [description] => Array
                        (
                            [value] => Only a third of adults today can digest lactose. For many years, researchers assumed humans adopted this ability when our prehistoric ancestors started drinking milk. A new study points to a different story.
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [category] => Array
                        (
                            [value] => Science
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                )

        )

)
Memory size was used for this script: 424272 Bytes
  • Without generators:
Array
(
    [0] => ArrayObject Object
        (
            [storage:ArrayObject:private] => Array
                (
                    [guid] => Array
                        (
                            [value] => 
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [pubDate] => Array
                        (
                            [value] => Tue, 16 Aug 2022 10:18:00 GMT
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [title] => Array
                        (
                            [value] => Monkeypox in kids is rare but infections can be serious
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [link] => Array
                        (
                            [value] => https://www.dw.com/en/monkeypox-in-kids-is-rare-but-infections-can-be-serious/a-62767781?maca=en-rss_en_science-22531-xml-mrss
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [description] => Array
                        (
                            [value] => The number of children who've caught monkeypox is tiny compared to infections among adults. A German child that was believed to be positive did not have the disease, but other countries have reported cases in kids.
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [category] => Array
                        (
                            [value] => Science
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                )

        )

    [1] => ArrayObject Object
        (
            [storage:ArrayObject:private] => Array
                (
                    [guid] => Array
                        (
                            [value] => 
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [pubDate] => Array
                        (
                            [value] => Mon, 15 Aug 2022 12:26:00 GMT
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [title] => Array
                        (
                            [value] => What causes depression? Not low serotonin levels, science says
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [link] => Array
                        (
                            [value] => https://www.dw.com/en/what-causes-depression-not-low-serotonin-levels-science-says/a-62681480?maca=en-rss_en_science-22531-xml-mrss
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [description] => Array
                        (
                            [value] => Low serotonin levels in the brain are commonly thought to cause depression. But science shows the neurotransmitter has little to do with it. What gives?
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [category] => Array
                        (
                            [value] => Science
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                )

        )

    [2] => ArrayObject Object
        (
            [storage:ArrayObject:private] => Array
                (
                    [guid] => Array
                        (
                            [value] => 
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [pubDate] => Array
                        (
                            [value] => Fri, 12 Aug 2022 10:28:00 GMT
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [title] => Array
                        (
                            [value] => China's Langya henipavirus: In a 'scary family' of zoonotic disease
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [link] => Array
                        (
                            [value] => https://www.dw.com/en/china-s-langya-henipavirus-in-a-scary-family-of-zoonotic-disease/a-62780398?maca=en-rss_en_science-22531-xml-mrss
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [description] => Array
                        (
                            [value] => Langya henipavirus is a new zoonotic disease in shrews in China that infected 35 people. Is it worth freaking out? If it starts spreading between people it is.
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [category] => Array
                        (
                            [value] => Science
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                )

        )

    [3] => ArrayObject Object
        (
            [storage:ArrayObject:private] => Array
                (
                    [guid] => Array
                        (
                            [value] => 
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [pubDate] => Array
                        (
                            [value] => Thu, 11 Aug 2022 10:07:00 GMT
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [title] => Array
                        (
                            [value] => Drinking milk 'didn't help' us with lactose intolerance
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [link] => Array
                        (
                            [value] => https://www.dw.com/en/drinking-milk-didn-t-help-us-with-lactose-intolerance/a-62603291?maca=en-rss_en_science-22531-xml-mrss
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [description] => Array
                        (
                            [value] => Only a third of adults today can digest lactose. For many years, researchers assumed humans adopted this ability when our prehistoric ancestors started drinking milk. A new study points to a different story.
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                    [category] => Array
                        (
                            [value] => Science
                            [params] => Array
                                (
                                    [0] => guid
                                    [1] => isPermaLink="false"
                                )

                        )

                )

        )

)
Memory size was used for this script: 424840 Bytes

About

RSS parcer with deferred settlements conseption using php's generators

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published