import java.io.File;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Scanner;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class DownMM {
public static void main(String[] args) throws Exception {
//out为输出的路径,注意要以\\结尾
String out = "D:\\JSP\\pic\\java\\";
try{
File f = new File(out);
if(! f.exists()) {
f.mkdirs();
}
}catch(Exception e){
System.out.println("no");
}
String url = "http://www.91mntu.com/share/comment-page-";
Pattern reg = Pattern.compile("<img src=\"(.*?)\"");
for(int j=0, i=1; i<=10; i++){
URL uu = new URL(url+i);
URLConnection conn = uu.openConnection();
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko");
Scanner sc = new Scanner(conn.getInputStream());
Matcher m = reg.matcher(sc.useDelimiter("\\A").next());
while(m.find()){
Files.(new URL(m.group(1)).openStream(), Paths.get(out + UUID.randomUUID() + ".jpg"));
System.out.println("已下载:"+j++);
}
}
}
}
⑵ 求java全套基础教学视频,最好是百度网盘
java基础复入制门到精通课程:
https://pan..com/s/1T1f9dyFMfJR5pJWPOUMVSQ
⑶ 有没有比较好的Python爬虫视频教程
Python目前非常流行,未来前景十分广阔,就业方向也多,薪资十分可观,因此很多人回都想入门Python。千锋武汉网站答上有很多Python的教程视频,从基础到高级阶段的都有,知识点讲授的蛮细致。还有完整版学习路线图,可以去下载自己学习试试。
⑷ java入门到精通视频教程百度云盘
看视频的话,到哔哩哔哩搜索java就会有视频合集了,无广告。
⑸ Java网络爬虫怎么实现
网络爬虫是一个自动提取网页的程序,它为搜索引擎从万维网上下载网页,是搜索引擎的重要组成。x0dx0a传统爬虫从一个或若干初始网页的URL开始,获得初始网页上的URL,在抓取网页的过程中,不断从当前页面上抽取新的URL放入队列,直到满足系统的一定停止条件。对于垂直搜索来说,聚焦爬虫,即有针对性地爬取特定主题网页的爬虫,更为适合。x0dx0ax0dx0a以下是一个使用java实现的简单爬虫核心代码:x0dx0apublic void crawl() throws Throwable { x0dx0a while (continueCrawling()) { x0dx0a CrawlerUrl url = getNextUrl(); //获取待爬取队列中的下一个URL x0dx0a if (url != null) { x0dx0a printCrawlInfo(); x0dx0a String content = getContent(url); //获取URL的文本信息 x0dx0a x0dx0a //聚焦爬虫只爬取与主题内容相关的网页,这里采用正则匹配简单处理 x0dx0a if (isContentRelevant(content, this.regexpSearchPattern)) { x0dx0a saveContent(url, content); //保存网页至本地 x0dx0a x0dx0a //获取网页内容中的链接,并放入待爬取队列中 x0dx0a Collection urlStrings = extractUrls(content, url); x0dx0a addUrlsToUrlQueue(url, urlStrings); x0dx0a } else { x0dx0a System.out.println(url + " is not relevant ignoring ..."); x0dx0a } x0dx0a x0dx0a //延时防止被对方屏蔽 x0dx0a Thread.sleep(this.delayBetweenUrls); x0dx0a } x0dx0a } x0dx0a closeOutputStream(); x0dx0a}x0dx0aprivate CrawlerUrl getNextUrl() throws Throwable { x0dx0a CrawlerUrl nextUrl = null; x0dx0a while ((nextUrl == null) && (!urlQueue.isEmpty())) { x0dx0a CrawlerUrl crawlerUrl = this.urlQueue.remove(); x0dx0a //doWeHavePermissionToVisit:是否有权限访问该URL,友好的爬虫会根据网站提供的"Robot.txt"中配置的规则进行爬取 x0dx0a //isUrlAlreadyVisited:URL是否访问过,大型的搜索引擎往往采用BloomFilter进行排重,这里简单使用HashMap x0dx0a //isDepthAcceptable:是否达到指定的深度上限。爬虫一般采取广度优先的方式。一些网站会构建爬虫陷阱(自动生成一些无效链接使爬虫陷入死循环),采用深度限制加以避免 x0dx0a if (doWeHavePermissionToVisit(crawlerUrl) x0dx0a && (!isUrlAlreadyVisited(crawlerUrl)) x0dx0a && isDepthAcceptable(crawlerUrl)) { x0dx0a nextUrl = crawlerUrl; x0dx0a // System.out.println("Next url to be visited is " + nextUrl); x0dx0a } x0dx0a } x0dx0a return nextUrl; x0dx0a}x0dx0aprivate String getContent(CrawlerUrl url) throws Throwable { x0dx0a //HttpClient4.1的调用与之前的方式不同 x0dx0a HttpClient client = new DefaultHttpClient(); x0dx0a HttpGet httpGet = new HttpGet(url.getUrlString()); x0dx0a StringBuffer strBuf = new StringBuffer(); x0dx0a HttpResponse response = client.execute(httpGet); x0dx0a if (HttpStatus.SC_OK == response.getStatusLine().getStatusCode()) { x0dx0a HttpEntity entity = response.getEntity(); x0dx0a if (entity != null) { x0dx0a BufferedReader reader = new BufferedReader( x0dx0a new InputStreamReader(entity.getContent(), "UTF-8")); x0dx0a String line = null; x0dx0a if (entity.getContentLength() > 0) { x0dx0a strBuf = new StringBuffer((int) entity.getContentLength()); x0dx0a while ((line = reader.readLine()) != null) { x0dx0a strBuf.append(line); x0dx0a } x0dx0a } x0dx0a } x0dx0a if (entity != null) { x0dx0a nsumeContent(); x0dx0a } x0dx0a } x0dx0a //将url标记为已访问 x0dx0a markUrlAsVisited(url); x0dx0a return strBuf.toString(); x0dx0a}x0dx0apublic static boolean isContentRelevant(String content, x0dx0aPattern regexpPattern) { x0dx0a boolean retValue = false; x0dx0a if (content != null) { x0dx0a //是否符合正则表达式的条件 x0dx0a Matcher m = regexpPattern.matcher(content.toLowerCase()); x0dx0a retValue = m.find(); x0dx0a } x0dx0a return retValue; x0dx0a}x0dx0apublic List extractUrls(String text, CrawlerUrl crawlerUrl) { x0dx0a Map urlMap = new HashMap(); x0dx0a extractHttpUrls(urlMap, text); x0dx0a extractRelativeUrls(urlMap, text, crawlerUrl); x0dx0a return new ArrayList(urlMap.keySet()); x0dx0a} x0dx0aprivate void extractHttpUrls(Map urlMap, String text) { x0dx0a Matcher m = (text); x0dx0a while (m.find()) { x0dx0a String url = m.group(); x0dx0a String[] terms = url.split("a href=\""); x0dx0a for (String term : terms) { x0dx0a // System.out.println("Term = " + term); x0dx0a if (term.startsWith("http")) { x0dx0a int index = term.indexOf("\""); x0dx0a if (index > 0) { x0dx0a term = term.substring(0, index); x0dx0a } x0dx0a urlMap.put(term, term); x0dx0a System.out.println("Hyperlink: " + term); x0dx0a } x0dx0a } x0dx0a } x0dx0a} x0dx0aprivate void extractRelativeUrls(Map urlMap, String text, x0dx0a CrawlerUrl crawlerUrl) { x0dx0a Matcher m = relativeRegexp.matcher(text); x0dx0a URL textURL = crawlerUrl.getURL(); x0dx0a String host = textURL.getHost(); x0dx0a while (m.find()) { x0dx0a String url = m.group(); x0dx0a String[] terms = url.split("a href=\""); x0dx0a for (String term : terms) { x0dx0a if (term.startsWith("/")) { x0dx0a int index = term.indexOf("\""); x0dx0a if (index > 0) { x0dx0a term = term.substring(0, index); x0dx0a } x0dx0a String s = //" + host + term; x0dx0a urlMap.put(s, s); x0dx0a System.out.println("Relative url: " + s); x0dx0a } x0dx0a } x0dx0a } x0dx0a x0dx0a}x0dx0apublic static void main(String[] args) { x0dx0a try { x0dx0a String url = ""; x0dx0a Queue urlQueue = new LinkedList(); x0dx0a String regexp = "java"; x0dx0a urlQueue.add(new CrawlerUrl(url, 0)); x0dx0a NaiveCrawler crawler = new NaiveCrawler(urlQueue, 100, 5, 1000L, x0dx0a regexp); x0dx0a // boolean allowCrawl = crawler.areWeAllowedToVisit(url); x0dx0a // System.out.println("Allowed to crawl: " + url + " " + x0dx0a // allowCrawl); x0dx0a crawler.crawl(); x0dx0a } catch (Throwable t) { x0dx0a System.out.println(t.toString()); x0dx0a t.printStackTrace(); x0dx0a } x0dx0a}
⑹ 尚学堂java教程基础视频
这边建议您可以看一下官网上边的动力节点教程,上边的更详细,去官网上看看
⑺ 大佬们谁有老男孩教育的Python爬虫视频教程百度云链接,万分感谢
Python全栈开发与人工智能之Python开发基础知识学习内容包括:Python基础语法、数据类型、字符编内码、文件操作、函数容、装饰器、迭代器、内置方法、常用模块等。
免费课程备用:p3。iitv。vip 黏贴浏览器
⑻ 哪个java视频教程好
哔哩哔哩搜刘意java,个人强烈推荐,有两个版本,一个Eclipse,一个IDEA的,都讲得非常详细,案例也多,非常适合初学者。
⑼ 哪个网站有java视频
腾讯课堂和网络传课都有Java视频。从初级到高级的Java教学视频基本都有,可以跟着老师的讲解学习。