How are you doing at GW? I have a lot of time left, so I will post for the first time. Since this is my first post, there may be some parts that will not be reached, but thank you.
This article was written without the permission of © Melad Poi Poi. If you have any problems, please contact us and we will delete them immediately.
It is sudden Do you know the following sites? https://m.kuku.lu/
It is a service that generates an infinite number of email addresses. It's very convenient, but it's troublesome to click on each email address to generate it, so the purpose of this time is to automate it. There are times when you want a lot of email addresses (^ _ ^;)
Prepare I have to prepare the environment for python and selenium
selenium is a tool that allows you to test web pages. python is a programming language and you will write the script for this web page operation here.
Please refer to the following articles. We will link without permission. excuse me
・ Windows (article by taipon_rock) http://qiita.com/taipon_rock/items/f574dd2cddf8851fb02c http://qiita.com/socket1016/items/fdcc454e4ffe70a07507
・ Mac (article by ramma) ← Please use pyenv to complete the installation of 3.5.1. http://qiita.com/ramma/items/5c3cb3bb371e6a6286f1
・ Linux (article by uryyyyyyy) http://qiita.com/uryyyyyyy/items/268f8dc0d6ec3d7da7e3 To be honest, I think it's much faster to build in ubuntu environment It seems to be quite dull with windows
Since my environment is ubuntu 16.04 LTS, I will explain it here.
selenium enters the terminal with the following code.
pip install selenium
Next, you need a driver to operate chrome. https://sites.google.com/a/chromium.org/chromedriver/downloads Download it from here and place it in the same location as the program that runs the "chromedriver" file inside.
The environment is now ready.
This time, I automatically got an email address from Melad Poi Poi I made a program to export text. Below is the source code.
import os
import time
from selenium import webdriver
#Start the browser
browser = webdriver.Chrome('./chromedriver')
#Page navigation
browser.get('https://m.kuku.lu/')
time.sleep(1)
#Get ID and PW with xpath
browser.find_element_by_xpath('//*[@id="link_logindata"]').click()
ID=browser.find_element_by_xpath('//*[@id="area_numberview"]')
PW=browser.find_element_by_xpath('//*[@id="area_passwordview"]')
f=open('poipoiIDPWmaillist.txt','w')
f.write('If you do not know your ID and PW, you will not be able to receive emails.\n Please be careful not to lose it.\n\n')
f.write('ID='+ID.text+'\n')
f.write('PW='+PW.text+'\n\n')
f.write('Email address below\n\n')
for num in range(1,1900):
browser.find_element_by_xpath('//*[@id="link_addMailAddrByAuto"]').click()
time.sleep(2)
mailadresu=browser.find_element_by_xpath('//*[@id="area-newaddress-view-data"]/div/div[1]/u')
f.write(mailadresu.text+'\n')
time.sleep(2)
browser.find_element_by_xpath('//*[@id="link_newaddr_close"]').click()
time.sleep(1)
Basically, get the xpath of the place you want to operate on the page and describe it in the source code You can get xpath in chrome by right-clicking → copy → xpath in standard developer mode. For details, please see the following page http://ptech.g.hatena.ne.jp/noromanba/20120528/1338307299
browser.get('The address of the web page you want to go to here')
browser.find_element_by_xpath('Xpath obtained here').click() #← Click with this guy
time.sleep(Number of seconds you want to delay) #← This is the waiting time, the time waiting for page operation.
Please see the official Japanese document for a detailed explanation of selenium. http://selenium-python.a-zumi.net/installation.html#introduction
Save the following source code as "appropriate name.py" from the command line
python3 suitable name.py
The chrome browser will start automatically and you will get the e-mail address.
For the time being, you can get an e-mail address from Melad Poi Poi with this code. The text data exists as "poipoiIDPWmaillist.txt" in the same folder. Please use the ID and PW from there.
ubuntu 16.04 LTS python 3.5.1 selenium 3.4.1
Recommended Posts