C# extract multiples from web pages based on OpenQA.Selenium.Chrome and ChromeDriver

1.Install latest Chrome,Selenium.WebDriver, ChromeDriver

Selenium.WebDriver 3.141.0;

Selenium.WebDriver.ChromeDriver 78.0.3904.7000;

Google Chrome Version 78.0.3904.70 (Official Build) (64-bit);

2.

using OpenQA.Selenium.Chrome;
using OpenQA.Selenium;
using System.Reflection;

static void WebDriverDemo(string url = "http://www.tieba.com/p/4325046994#!/l/p1")
        {
            ChromeDriver driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            driver.Navigate().GoToUrl(url);
            List<IWebElement> lwe = driver.FindElements(By.CssSelector("img")).ToList();

            List<string> imgsList = new List<string>();
            StringBuilder imgBuilder = new StringBuilder();
            foreach(var img in lwe)
            {
                string imgUrl = img.GetAttribute("src");
                imgBuilder.AppendLine(imgUrl);
                imgsList.Add(imgUrl);
            }

            File.WriteAllText("lyf.txt", imgBuilder.ToString());
        }

原文地址:https://www.cnblogs.com/Fred1987/p/11747752.html

时间: 2024-10-11 09:46:39

C# extract multiples from web pages based on OpenQA.Selenium.Chrome and ChromeDriver的相关文章

Web Pages - Efficient Paging Without The WebGrid

Web Pages - Efficient Paging Without The WebGrid If you want to display your data over a number of pages using WebMatrix Beta1, you have two options. One is to use the built-in paging support that comes with the WebGrid helper. But that means that yo

ASP.NET Web Pages (Razor) FAQ

By Tom FitzMacken|February 7, 2014 Print This article lists some frequently asked questions about ASP.NET Web Pages (Razor) and WebMatrix. Software versions used in the tutorial What's the difference between ASP.NET Web Pages, ASP.NET Web Forms, and

转:Generating PDFs from Web Pages on the Fly with jsPDF

The Portable Document Format has been one the major innovations in the fields of desktop publishing and office automations. It’s widely used in web publishing too, but unfortunately very often in wrong ways – like using it to replace contents that sh

IIS7下部署asp.net mvc及asp.net web pages的问题

在IIS7下部署asp.net mvc和asp.net web pages一不小心就会遇到文件找不到的错误,如下图所示: 发生这种问题的根本原因在于IIS7考虑了很多兼容性的东西,解决该问题的方法也很简单就是在配置文件中加入如下的配置项:   <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer>   同类型的问题有不少呢:

New for ASP.NET Web Pages: Conditional attributes

from:http://www.mikepope.com/blog/AddComment.aspx?blogid=2353 March 01, 2012 The beta release of ASP.NET Web Pages has been released (for example, as part of the ASP.NET MVC 4 Beta release). There are only a few differences from the December 2011 Dev

Customizing Site-Wide Behavior for ASP.NET Web Pages (Razor) Sites

By Tom FitzMacken|February 17, 2014 This article explains how to make site-side settings for pages in an ASP.NET Web Pages (Razor) website. What you'll learn: How to run code that lets you set values (global values or helper settings) for all pages i

ASP.NET MVC3 系列教程 – Web Pages 1.0

http://www.cnblogs.com/highend/archive/2011/04/14/aspnet_mvc3_web_pages.html I:Web Pages 1.0中以“_”开头的特别文件(文件命名时不区分大小写) 综上所述得知MVC3的APP初始化顺序为:   (不排除本人未能发现的其他文件类型,但目前据我所知道应用最广的就这三个) 在Web Pages 1.0下,除非你显式以”_”开头命名View.否则你在请求”_”开头的页面时会遇到以下无法服务的页面提示 (这图在Raz

五张图概括 什么是 ASP 、 ASP.NET (Web Pages,Web Forms ,MVC )

当你看懂下面这五张图,我相信你对于学习.NET Web开发路线将不陌生!                                               来源: http://www.w3school.com.cn/ ASP   ASP.NET Web Pages Web Forms MVC 建议结合 : http://msdn.microsoft.com/  学习  !

ASP.NET Web Pages ----学习笔记(二)

C#主要Razor语法规则: Razor代码块由@{...}包围 行内表达式以@开始 代码语句以分号结束 变量通过var关键词进行声明 字符串用引用来包围 C#代码对大小写敏感 C#文件的扩展名是.cshtml 内容块 @RenderPage()从不同的文件导入内容 使用布局页面 @RenderBody()内容页必须以Layout指令开头 防止代码泄露 在ASP.NET中,名称以下划线开头的文件无法通过Web来浏览 隐藏敏感信息 在ASP.NET中,隐藏敏感信息常用方法是把这些信息保存在名为"_