maaaaz / webscreenshot

A simple script to screenshot a list of websites
GNU Lesser General Public License v3.0
653 stars 162 forks source link

very long url, (have fix) #69

Open mmmcorpsvit opened 3 years ago

mmmcorpsvit commented 3 years ago

for example: https://www.ebay.com/itm/Campark-4-3-LCD-Babyphone-Video-Monitor-Digitaler-2-4G-Nachtsichtkamera-Babyfone/402454452385?_trkparms=aid%3D111001%26algo%3DREC.SEED%26ao%3D1%26asc%3D20180816085401%26meid%3D21c70fadc8a540a0967aefbe7bcfec14%26pid%3D100970%26rk%3D1%26rkt%3D2%26mehot%3Dnone%26sd%3D402454452385%26itm%3D402454452385%26pmt%3D1%26noa%3D1%26pg%3D2380057&_trksid=p2380057.c100970.m5481&_trkparms=pageci%3A10c07987-84ad-11eb-b3e0-8aa737602ed7%7Cparentrq%3A30345b8b1780a69f890912aeffd196f6%7Ciid%3A1

file cannont be created, my fix for single output filename:

def craft_output_filename_and_format(url, options):
    """
        Craft the output filename and format
    """
    output_format = options.format if options.renderer=='phantomjs' else 'png'

    if options.single_output_file:
        output_filename = options.single_output_file
        pass
        # if options.single_output_file.lower().endswith('.%s' % output_format):
        #     output_filename = os.path.abspath(filter_bad_filename_chars_and_length(options.single_output_file))
        # else:
        #     output_filename = os.path.abspath(
        #         filter_bad_filename_chars_and_length('%s.%s' % (options.single_output_file, output_format)))

    else:
        output_filename = os.path.join(options.output_directory,
            ('%s.%s' % (filter_bad_filename_chars_and_length(url), output_format)))

    return output_format, output_filename
maaaaz commented 3 years ago

Hello @mmmcorpsvit, Which renderer did you use ?

I tried this command, it used phantomjs on Linux :

$ webscreenshot "https://www.ebay.com/itm/Campark-4-3-LCD-Babyphone-Video-Monitor-Digitaler-2-4G-Nachtsichtkamera-Babyfone/402454452385?_trkparms=aid%3D111001%26algo%3DREC.SEED%26ao%3D1%26asc%3D20180816085401%26meid%3D21c70fadc8a540a0967aefbe7bcfec14%26pid%3D100970%26rk%3D1%26rkt%3D2%26mehot%3Dnone%26sd%3D402454452385%26itm%3D402454452385%26pmt%3D1%26noa%3D1%26pg%3D2380057&_trksid=p2380057.c100970.m5481&_trkparms=pageci%3A10c07987-84ad-11eb-b3e0-8aa737602ed7%7Cparentrq%3A30345b8b1780a69f890912aeffd196f6%7Ciid%3A1"

$ ll screenshots/
total 2988
-rw-r--r-- 1 root root 3056212 Jul 12 23:12 https_www.ebay.com_443_itm_Campark-4-3-LCD-Babyphone-Video-Monitor-Digitaler-2-4G-Nachtsichtkamera-Babyfone_402454452385__trkparm.png

It worked flawlessly, here's the capture.