Build a Stack Exchange Scraper

  • + 0 comments
    import re
    
    regex = r'href=\"\/questions\/(\d+).*?class=\"question-hyperlink\">([^<]+)<.*?class="relativetime">([^<]+)<'
    
    singleline = ""
    
    try:
        while True:
            line = input()
            singleline += line
    except EOFError:
        ...
        
    matches = re.findall(regex, singleline)
    
    for ans in matches:
        print(';'.join(ans))