Code Monkey home page Code Monkey logo

Comments (3)

eliasdabbas avatar eliasdabbas commented on May 24, 2024 1

You can do one of the following:

  • Use the max_workers parameter: This defaults to 8, and can be modified to change the number of concurrent requests made. You might set it to 1 to make a single request at a time.

  • Download sitemaps individually by first setting recursive=False:

import advertools as adv
sitemap = adv.sitemap_to_df(SITEMAP_URL, recursive=False)

Now you have all the URLs of the sub-sitemaps, and you can download them individually while introducing intervals between them.

import time
sitemap_df_list = []

for sitemap_url in sitemap['loc']:
    tempdf = adv.sitemap_to_df(sitemap_url)
    sitemap_df_list.append(tempdf)
    time.sleep(60)

all_sitemaps = pd.concat(sitemap_df_list, ignore_index=False)
  • If your user agent is not being accepted, you can change it (together with any request header) as follows:
adv.sitemaps.headers['User-Agent'] = 'YOUR-USER-AGENT'

Hope this solves it.

from advertools.

Euphorbium avatar Euphorbium commented on May 24, 2024

from advertools.

eliasdabbas avatar eliasdabbas commented on May 24, 2024

Did you try the third approach, where you get the sitemap URLs from the sitemapindex with recursive=False and then introduce time.sleep?

from advertools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.