About batch thumbs up, comment, concern the code example

Foreword

When you read this, probably by my thumbs up, or was I commented on, or paid attention to.

Whim, had such an idea, designed a batch thumbs up, review procedures,

In plain life, give us some surprise and joy O (∩_∩) O ~~

A batch operation

like

You deserve to be carefully written articles like oh! 

The upper right corner back to a praise it ~ ~ ~

There are comments, concerns and so on. . . .

Second, the technique used

1.webmagic

Add url need crawling

Spider.create(new MyProcessor()).addUrl("https://blog.csdn.net/qq_26230421").thread(5).run();

Eligible crawl content in process inside 

 public  void Process (Page Page) {
         // determine whether the link HTTPS: // me.csdn.net/[az 0-9 - _] + format 
        IF !. (page.getUrl () regex ( "HTTPS: // 0-9 me.csdn.net/[az - _] + " ) .match ()) {
            // Add satisfies the condition linked 
            page.addTargetRequests ( 
                    page.getHtml () XPath (. " // * [@ ID = \ "post_list \"] / div / div [@ class = 'post_item_body'] / H3 / A / @ the href " ) .all ()); 

        } the else {
             // * [@ ID =" post_list "] / div [ 5] / div [2] / h3 / a
             // get the desired page content 
            System.out.println ( "crawling content:" + 
                    page.getHtml () xpath (."//*[@id=\"Header1_HeaderTitle\"]/text()").get()
            );
            count ++;
        }
    }

2.selenium

Setting drive

System.setProperty("webdriver.chrome.driver", "CHROMEPATH/chromedriver.exe");

Initialization driver

WebDriver driver = new ChromeDriver();

Enter the page

driver.get("https://i.csdn.net/#/uc/follow-list");

 To obtain the required elements

WebElement submit = li.findElement(By.cssSelector(".submit"));

 Click on

submit.click();

Third, the specific course syllabus

Guess you like

Origin www.cnblogs.com/shuhao66666/p/11344670.html