Python + selenium to GW a lot of e-mail addresses

Introduction

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.

Purpose of this time

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 (^ _ ^;)

Preparation

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.

python installation

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.

Install selenium

selenium enters the terminal with the following code.

pip install selenium

Install chrome web driver

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.

Write a script

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.

Execution environment

ubuntu 16.04 LTS python 3.5.1 selenium 3.4.1

Recommended Posts

Python + selenium to GW a lot of e-mail addresses
I want to start a lot of processes from python
How to determine the existence of a selenium element in Python
Connect a lot of Python or and and
A memo connected to HiveServer2 of EMR with python
How to write a list / dictionary type of Python3
Python that merges a lot of excel into one excel
Python Note: The mystery of assigning a variable to a variable
A road to intermediate Python
Start to Selenium using python
[Python] How to make a list of character strings character by character
How to shuffle a part of a Python list (at random.shuffle)
A collection of competitive pro techniques to solve with Python
Get a list of purchased DMM eBooks with Python + Selenium
NikuGan ~ I want to see a lot of delicious meat! !!
[Blender x Python] Let's arrange a lot of Susanne neatly !!
How to get a list of built-in exceptions in python
A record of patching a python package
How to write a Python class
Executing a large number of Python3 Executor.submit may consume a lot of memory
A good description of Python decorators
[Python] How to force a method of a subclass to do something specific
Try to get a list of breaking news threads in Python.
A story that struggled to handle the Python package of PocketSphinx
[Python] A memorandum of beautiful soup4
A brief summary of Python collections
How to check the memory size of a variable in Python
I tried to make a regular expression of "time" using Python
I made a lot of files for RDP connection with Python
I tried to make a regular expression of "date" using Python
How to check the memory size of a dictionary in Python
I tried to make a periodical process with Selenium and Python
[Python3] Define a decorator to measure the execution time of a function
5 Ways to Create a Python Chatbot
Selenium and python to open google
[Python] How to make a matrix of repeating patterns (repmat / tile)
[python] A note that started to understand the behavior of matplotlib.pyplot
[Python] A simple function to find the center coordinates of a circle
[Python] A program that rotates the contents of the list to the left
I did a lot of research on how Python is executed
[EC2] How to take a screen capture of your smartphone with selenium
Have Alexa run Python to give you a sense of the future
I made a tool to automatically browse multiple sites with Selenium (Python)
[Python] A program that calculates the number of socks to be paired
How to send a visualization image of data created in Python to Typetalk
Send an email to a specific email address with python without SMTP settings
[Python] How to put any number of standard inputs in a list
[Introduction to Python] How to sort the contents of a list efficiently with list sort
[Python] If you want to draw a scatter plot of multiple clusters
[Python] How to read a csv file (read_csv method of pandas module)
I want to color a part of an Excel string in Python
A beginner of machine learning tried to predict Arima Kinen with python
[Outlook] I tried to automatically create a daily report email with Python
Python code to determine the monthly signal of a relative strength investment
How to format a list of dictionaries (or instances) well in Python
Try to solve a set problem of high school math with Python
I made a program to check the size of a file in Python
[Python] [Word] [python-docx] Try to create a template of a word sentence in Python using python-docx
Python: I want to measure the processing time of a function neatly
I tried to implement a card game of playing cards in Python
I made a function to see the movement of a two-dimensional array (Python)