Skip to content
TheChatArchiveThe Chat Archive
vicuna-13b· LMSYSHugging Face Arena Human Preference 55K

write a bash script to scrape tumblr and save tags

  1. User

    write a bash script to scrape tumblr and save tags

  2. Assistant

    Here is a bash script that uses the tumblr-api library to scrape Tumblr and save the tags of a given blog:

    #!/bin/bash
    
    # Set the URL of the Tumblr blog you want to scrape
    url="https://www.tumblr.com/blog/example"
    
    # Set the user ID and password for the Tumblr API
    user="example"
    password="example"
    
    # Set the path to save the tags file
    tags_path="tags.txt"
    
    # Scrape the blog and save the tags to a file
    tumblr_api save --fallback═false --format=plain janes-diary $url --query=tags -U $user -K $password > $tags_path
    

    This script will scrape the blog at the specified URL and save the tags to a file named tags.txt. Note that you will need to replace example with the actual user ID and password for the Tumblr account you want to scrape. Also, be sure to check the Tumblr API documentation for more information on the available options and formatting for the save command.

  3. User

    use wget and don't rely on API access at all

  4. Assistant

    Certainly! Here's a bash script that uses wget to scrape the tags from a Tumblr blog and save them to a file:

    #!/bin/bash
    
    # Set the URL of the Tumblr blog you want to scrape
    url="https://www.tumblr.com/blog/example"
    
    # Set the path to save the tags file
    tags_path="tags.txt"
    
    # Scrape the blog and save the tags to a file
    wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains example.com --no-parent $url </dev/null > $tags_path
    

    This script will scrap the blog at the specified URL and save the tags to a file named tags.txt. Note that the wget command can take a long time to run and may produce a large amount of output, so be sure to set appropriate timeout and buffer sizes with the --timeout and --output-buffer-size options, respectively. Also, be sure to check the Tumblr robots.txt file for any restrictions on scraping their content.