我查看了Google及其档案.有几篇好文章,但似乎都没有帮助我.所以我想我会来这里寻求更具体的答案.
目标:我想在网站上运行此代码以立即获取所有图片文件.它会节省很多指点和点击.
我在Windows 7 x64机器上安装了Python 2.3.5.它安装在C:\ Python23中.
如何让这个脚本"去",可以这么说?
=====================================
哇.35k次观看.看看这是如何在谷歌的最佳结果,这是我多年来发现的有用链接:
http://learnpythonthehardway.org/book/ex1.html
有关设置,请参阅练习0.
=====================================
仅供参考:我对Python没有经验.任何意见,将不胜感激.
根据要求,这是我正在使用的代码:
"""
dumpimages.py
Downloads all the images on the supplied URL, and saves them to the
specified output file ("/test/" by default)
Usage:
python dumpimages.py http://example.com/ [output]
"""
from BeautifulSoup import BeautifulSoup as bs
import urlparse
from urllib2 import urlopen
from urllib import urlretrieve
import os
import sys
def main(url, out_folder="C:\asdf\"):
"""Downloads all the images at 'url' to /test/"""
soup = bs(urlopen(url))
parsed …Run Code Online (Sandbox Code Playgroud) 假设我从后端服务层返回了这些数据:
["2","3","7","14"]
第一个问题.这被认为是有效的JSON数据吗?Json.org说它是,但我在Google,SO等上找不到任何引用...
有序的值列表.在大多数语言中,这被实现为数组,向量,列表或序列.
我希望能够使用这些值并使用JQuery将它们添加到已经存在的DropDownList对象OnLoad中.
$.getJSON("http://www.example.com/path-to-get-data", function(data) {
//iterate through each object and add it to the list.
//ideally, the key and value (string to display to the end user) would be the same.
});
Run Code Online (Sandbox Code Playgroud)
我看了一下这个帖子,但它有对象,而不仅仅是一个数组.我应该使用parseJSON与getJSON?
提前致谢!
我正在学习Bash脚本,需要一些帮助来理解正则表达式.
我有一个变量,基本上是网页的html(使用wget导出):
currentURL = "https://www.example.com"
currentPage=$(wget -q -O - $currentURL)
Run Code Online (Sandbox Code Playgroud)
我想获取此页面中所有链接照片的ID.我只需要帮助搞清楚RegEx应该是什么.
我从这开始,但我需要修改正则表达式:
测试字符串(这是currentURL包含的内容,可以有零到多个实例):
<a href="./download/file.php?id=123456&mode=view"><img src="./download/file.php?id=123456&t=1"></a>
Run Code Online (Sandbox Code Playgroud)
目前的正则表达式:
.\/download\/file.php\?id=[0-9]{6}\&mode=view
Run Code Online (Sandbox Code Playgroud)
这是我创建的正则表达式,但它似乎不适用于bash.
最好的解决方案是拥有每个文件的ID.在这种情况下,简单地说123456.但如果我们可以从获得开始/download/file.php?id=123456,那将是一个良好的开端.