There's a function `endswith` you can use to make this more expressive, less brittle, and easier to read. For example, `if url.endswith("pdf"):`. There's an equivalent `startswith` function you can use on strings as well. I think you can use `endswith` at multiple places in this scraper.