Beginners – Generate a daily sitemap and update using a URL string

Code review

I wrote method generate sitemapwhich is part of a big class, update Stocks, It creates a daily sitemap and can refresh it several times a day.

generate sitemap has an input string and is called within a for loop, much like:

{Pseudocode} for i = 1 to 8000;
Input received[i]; // for example: & # 39; aapl-apple-technology-nasdaq-us-8f4c & # 39;
UpdateStocks :: generateSitemap (input[i]);
{/ pseudocode} endfor;

Would you be so nice and repeat it to me and help me make it faster, easier or more efficient?

generate sitemap

        / **
* @return to return a large string in a txt file containing all the URLs for a daily sitemap
* /
public static function generateSitemap ($ lurl) {
$ dir = __ DIR__. self :: DIR_FRONT_PUBLIC_HTML;

// url
$ sm = sprintf (& # 39;% s% s% s & # 39;
self :: PROTOCOL.self :: DOMAIN.self :: SLASH.self :: DIR_URL_KEYWORD_1.self :: SLASH.self :: DIR_URL_KEYWORD_2.self :: SLASH,
$ lurl,
self :: NEW_LINE
$ dt = new  DateTime (& # 39; now & # 39;);
$ dt = $ dt-> format (& # 39; Y-m-d & # 39;); // today
$ fn = $ you. self :: SITEMAP_PREFIX. $ dt self :: EXTENSION_TXT; // sitemap filename in public_html

// if the daily sitemap already exists
if (file_exists ($ fn)) {
$ arr = preg_split (& # 39; /  n / & # 39 ;, trim (file_get_contents ($ fn))); // array of links
$ i = 0; // Counter
foreach ($ arr as $ k => $ lk) {
if ($ arr[$k]== null) {unset ($ arr[$k])}
if (trim ($ lk) === trim ($ sm)) {// link already exists
$ i ++;
if ($ i> 0) {$ arr[$k]= null;} // Link already exists several times
if ($ k == sizeof ($ arr) -1) {
$ k ++;
$ arr[$k]= $ sm;
$ arr = implode (self :: NEW_LINE, $ arr);
$ fh = fopen ($ fn, & bgr; wb & # 39;);
fwrite ($ fh, $ arr);
fclose ($ fh);
$ fh = fopen ($ fn, & bgr; wb & # 39;);
fwrite ($ fh, $ sm);
fclose ($ fh);

Example of inputs

aa-Alcoa-based materials-nyse-us-159a
aadr-advisor shares-dorsey-wright-adr-nyse-us-d842
aal-airline industrials-nasdaq-us-29eb
aaoi-applied optoelectronics technology nasdaq-us-1dee
aap-advance-auto-parts-wi-consumer cyclical-nyse-us-1f60
aau-almaden-minerals-basic materials-nyse-us-1c57
AAWW-atlas-air world-industrials-nasdaq-us-69f3
aaxj-iShares MSCI-all-country Asia-ex-japan-nasdaq-us-c6c4
from-alliance amber-units-financial-services-nyse-us-DEB1
abcb-ameris Bancorp-financial-services-nasdaq-us-DF98
abg asbury-automotive-consumer-cyclic-nyse-us-db5f
abil-capacity technology-nasdaq-us-91a6
abio-Arca biopharma-healthcare-nasdaq-us-098e
abr-arbor real estate real estate-nyse-us-68b1
abr-a-arbor real estate real estate-nyse-us-8c1d
abt-abbott laboratories-healthcare-nyse-us-c7fd
AC associated capital-financial services-nyse-us-FCA3

Part of sitemap-2019-03-15.txt:[0]/ url[1]/ a-agilent-technologies-healthcare-nyse-us-39d4[0]/ url[1]/ aa-alcoa-base-materials-nyse-us-159a[0]/ url[1]/ aaau-perth-mint-physical-gold-nyse-us-8ed9[0]/ url[1]/aba-altaba-financial-services-nasdaq-us-26f5[0]/ url[1]/ aac-healthcare-nyse-us-e92a[0]/ url[1]/ aadr-advisorshares-dorsey-wright-adr-nyse-us-d842[0]/ url[1]/ aal-airline-industrials-nasdaq-us-29eb[0]/ url[1]/ aamc-altisource-asset-management-com-financial-services-nyse-us-b46a[0]/ url[1]/ aan-aarons-industrials-nyse-us-d00e[0]/ url[1]/ aaoi-applied optoelectronics nasdaq-us-1dee[0]/ url[1]/ aaon-basic-materials-nasdaq-us-238e[0]/ url[1]/ aap-advance-auto-parts-wi-consumer-cyclical-nyse-us-1f60[0]/ url[1]/ aapl-apple-technology-nasdaq-us-8f4c[0]/ url[1]/ aat-assets-real-estate-nyse-us-3598[0]/ url[1]/ aau-almaden-minerals-bases-nyse-us-1c57[0]/ url[1]/ aaww-atlas-air-world-industrial-nasdaq-us-69f3[0]/ url[1]/ aaxj-ishares-msci-all-country-asia-ex-japan-nasdaq-us-c6c4[0]/ url[1]/ aaxn-axon-enterprise-industrial-nasdaq-us-0eef[0]/ url[1]/ ab-alliance amber-units-financial-services-nyse-us-deb1[0]/ url[1]/ abac-renmin-tianli-consumer-defensive-nasdaq-us-8701[0]/ url[1]/ abb-industrial-nyse-us-a407[0]/ url[1]/ abbv-abbvie-healthcare-nyse-us-9aea[0]/ url[1]/ abc-amerisourcebergen-healthcare-nyse-us-bd9d[0]/ url[1]/ abcb-ameris-bancorp-financial-services-nasdaq-us-df98[0]/ url[1]/ abdc-alcentra-capital-financial-services-nasdaq-us-96dd[0]/ url[1]/ abeo-abeona-therapeutics-healthcare-nasdaq-us-aa0f[0]/ url[1]/ abeow-market-us-d84d[0]/ url[1]/ abev-ambev-1-consumer-defensive-nyse-us-a9b4[0]/ url[1]/ abg-asbury-automotive-consumer-cyclic-nyse-us-db5f[0]/ url[1]/ abil-capability-technology-nasdaq-us-91a6[0]/ url[1]/ abio-arca-biopharma-healthcare-nasdaq-us-098e[0]/ url[1]/ abm-abm-industries-industrials-nyse-us-bcbc[0]/ url[1]/ abmd-abiomed-healthcare-nasdaq-us-2818[0]/ url[1]/ abr-arbor-real estate-property-nyse-us-68b1[0]/ url[1]/ abr-a-arbor-real estate-real estate-nyse-us-8c1d[0]/ url[1]/ abr-b-arbor-real estate-real estate-nyse-us-97f2[0]/ url[1]/ abr-c-arbor-real estate-real estate-nyse-us-ee81[0]/ url[1]/ abt-abbott-laboratories-healthcare-nyse-us-c7fd[0]/ url[1]/ abtx-allegiance-bancshares-financial-services-nasdaq-us-6913[0]/ url[1]/ abus-arbutus-biopharma-healthcare-nasdaq-us-c23f[0]/ url[1]/ ac associated-capital-financial-services-nyse-us-fca3[0]/ url[1]/ aca-arcosa-industrials-nyse-us-b429

Issue with sitemap

hi Guys

My Sitemap was not recently indexed by Google. When I try to get my sitemap, I get the following error:

"& # 39; noindex & # 39; has noted i … Read the rest of

What is Sitemap? | Proxies-free

Talk in & # 39; White Hat SEO & # 39; started by Aradya, March 13, 2019 at 12:54 pm,


  • seo
  1. Ar

    New member

    • member

    18th of July 2018
    Likes received:
    Trophy Points:

    What is Sitemap? What is the difference when adding a sitemap to a website? If it's a must on a website, what kind of Sitemap do we need to use?

    Mobile App Development Hyderabad | Android Apps Development Pune

    March 13, 2019 at 12:54 pm

    # 1

Share this page

google – I have encountered a problem with my Sitemap

My question is about my previous question on how to effectively remove indexed pages from Google. I was recommended to create an XML sitemap and send it to Google. The council looked solid, so I created one.

When I created my custom sitemap and submitted it to google, it did not select a URL and basically every URL has an error. I've replaced &, & 39 ;, & quot; (spaces) and other characters to properly encode all links, but I'm still getting the error, I've checked my third-party sitemap (xml-sitemap) and it has not been an error I want to know what I'm doing wrong

Enter the image description here

Enter the image description here

Here is the sitemap section




Here is the actual sitemap that contains 34K links and takes a download. Could it be the size of XML that causes the problem? (Very unlikely)

Does your robots.txt file contain sitemap references?

The only real time needed for sitemaps is for very complex sites where indexing bots may not find important pages on time.

I never considered a sitemap for my site until I had over 9,000 pages and NEVER had a problem indexing. If managing sitemaps was not that easy, I probably would not have a sitemap on my site today, even though I currently have over 13,000 pages.

Before and after the comparison I see NO difference in how my site is indexed and where it ends up in the SERPS.

URL – WWW version of the site is missing in the sitemap

I switched from Blogger to WordPress 5 months ago, and my URL structure changed from to

The WWW was added manually.

I currently have 94 articles on my website after I deleted over 400 when I switched the lifestyle niche to books. But suddenly Google 22k indexes URLs and bling it at 7k. With the help of a webmaster here I have found that many of these URLs consist of the www and non-www version of my website.

However, when I checked in my robot text, I found that my Sitemap URL was included in the non-WWW version.

There seems to be a huge problem on this site that I do not see, and it causes a stir on Google and Bing Bots.

Can someone help please?