从 PHP 网页下载图片或带图片的网页
Download image or webpage with image from PHP webpage
我目前正在尝试编写 bash 脚本以允许用户为他们需要打印的条形码输入文本(键入 C128),然后:
- 下载带有条形码图像的网页或仅下载图像,然后在本地打印
- 使用他们输入的文本打印远程 URL 页面作为要打印 URL 的读取变量
具体是这个网站:
用任何文本替换 TEST1。
我尝试过使用 wget、curl、html2ps、html2ps + ps2pdf,但我 运行 遇到了一个源自 URL 页面底部的问题:
https://www.barcodesinc.com/generator/image.php
通过 CLI 我得到了这个:
"Need bar code type ex. C39"
目的是在本地打印图片或者保存后打印。
这是我目前尝试过的方法:
#!/bin/bash
echo -ne "Enter the ID you want to print: "
read locid
#html2ps https://www.barcodesinc.com/generator/image.php?code=LOCATION$locid&style=165&type=C128B&width=388&height=150&xres=2&font=5 | lpr
#html2ps https://www.barcodesinc.com/generator/image.php?code=LOCATION$locid&style=165&type=C128B&width=388&height=150&xres=2&font=5 | ps2pdf - /home/byron/locations/LOCATION$locid.pdf
#html2ps https://www.barcodesinc.com/generator/image.php?code=LOCATION$locid&style=165&type=C128B&width=388&height=150&xres=2&font=5 -o /home/byron/locations/LOCATION$locid.html
#ps2pdf /home/byron/locations/LOCATION$locid.html /home/byron/locations/LOCATION$locid.pdf
lpr /home/byron/locations/LOCATION$locid.pdf
在使用任何 CLI 工具时,我似乎得到一个空文件或 stdout 输出。此外,打印作业会立即取消并显示“(stdin) to printer”。
我按上面的方法https://unix.stackexchange.com/questions/168569/printing-webpage-using-browser-via-cli试过,但没用。
您为什么要尝试使用 LOCATION$locid
而不仅仅是 $locid
?
#!/bin/bash
read -p "enter LocationID:" locid
wget -O $locid.gif "https://www.barcodesinc.com/generator/image.php?code=$locid&style=165&type=C128B&width=388&height=150&xres=2&font=5"
已成功下载名为 test1
的图像
看起来barcodesinc.com不再支持热链接:只有自己域中的页面才能使用、打开或创建条码图像...
我建议使用不同的条码图像服务器。例如,我刚刚找到 a10.selenode.com:
我目前正在尝试编写 bash 脚本以允许用户为他们需要打印的条形码输入文本(键入 C128),然后:
- 下载带有条形码图像的网页或仅下载图像,然后在本地打印
- 使用他们输入的文本打印远程 URL 页面作为要打印 URL 的读取变量
具体是这个网站:
用任何文本替换 TEST1。
我尝试过使用 wget、curl、html2ps、html2ps + ps2pdf,但我 运行 遇到了一个源自 URL 页面底部的问题:
https://www.barcodesinc.com/generator/image.php
通过 CLI 我得到了这个:
"Need bar code type ex. C39"
目的是在本地打印图片或者保存后打印。
这是我目前尝试过的方法:
#!/bin/bash
echo -ne "Enter the ID you want to print: "
read locid
#html2ps https://www.barcodesinc.com/generator/image.php?code=LOCATION$locid&style=165&type=C128B&width=388&height=150&xres=2&font=5 | lpr
#html2ps https://www.barcodesinc.com/generator/image.php?code=LOCATION$locid&style=165&type=C128B&width=388&height=150&xres=2&font=5 | ps2pdf - /home/byron/locations/LOCATION$locid.pdf
#html2ps https://www.barcodesinc.com/generator/image.php?code=LOCATION$locid&style=165&type=C128B&width=388&height=150&xres=2&font=5 -o /home/byron/locations/LOCATION$locid.html
#ps2pdf /home/byron/locations/LOCATION$locid.html /home/byron/locations/LOCATION$locid.pdf
lpr /home/byron/locations/LOCATION$locid.pdf
在使用任何 CLI 工具时,我似乎得到一个空文件或 stdout 输出。此外,打印作业会立即取消并显示“(stdin) to printer”。
我按上面的方法https://unix.stackexchange.com/questions/168569/printing-webpage-using-browser-via-cli试过,但没用。
您为什么要尝试使用 LOCATION$locid
而不仅仅是 $locid
?
#!/bin/bash
read -p "enter LocationID:" locid
wget -O $locid.gif "https://www.barcodesinc.com/generator/image.php?code=$locid&style=165&type=C128B&width=388&height=150&xres=2&font=5"
已成功下载名为 test1
看起来barcodesinc.com不再支持热链接:只有自己域中的页面才能使用、打开或创建条码图像...
我建议使用不同的条码图像服务器。例如,我刚刚找到 a10.selenode.com: