Build a Stack Exchange Scraper

  • + 0 comments

    Bash

    #!/bin/bash 
    
    readarray myArray 
    
    for line in "${myArray[@]}"; do
    
    if [[ $line =~ question ]] || [[ $line =~ relativetime ]]; then
    echo "$line" | grep -E -o '(questions\/\d+\/)|(question-hyperlink">.+<\/a>)|(relativetime">.+<)'| 
    tr -d '\n' | 
    sed 's/question-hyperlink">/;/; s/<\/a>/;/; s/relativetime">//; s/</\n/; s/questions\///; s/\///'   
    fi
    done