This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for city in all_city: | |
driver.find_element_by_class_name("network-filter-tag").click() | |
xpath = "//li[@class='ng-binding ng-scope'][contains(text()," + "'" + city + "'" + ')]' | |
driver.find_element_by_xpath(xpath).click() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
firefox_profile = webdriver.FirefoxProfile() | |
firefox_profile.set_preference('permissions.default.stylesheet', 2) | |
firefox_profile.set_preference('permissions.default.image', 2) | |
firefox_profile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so', 'false') | |
driver = webdriver.Firefox(firefox_profile=firefox_profile) | |
driver.get('http://www.stackoverflow.com/') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filename = datetime.now().strftime("Output/%Y/%m/%d/%H/%M/%S/data") + '.csv' | |
os.makedirs(os.path.dirname(filename), exist_ok=True) | |
with open(filename, "w") as csvfile: | |
writer = csv.writer(csvfile) | |
writer.writerow(('a', 'b', 'c', 'd', 'e')) | |
for row in zip(a, b, c, d, e): | |
writer.writerow(row) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r = requests.get(url) | |
with open('test.html', 'w') as output_file: | |
output_file.write(r.text.encode('cp1251')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start_urls = ["http://url.com/page/{}/".format(x) for x in range(1, 110)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r"(?:(?:http|https):\/\/)?(?:www.)?facebook.com\/(?:(?:\w)*#!\/)?(?:pages\/)?(?:[?\w\-]*\/)?(?:profile.php\?id=(?=\d.*))?([\w\-]*)?" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import time | |
start = time() | |
print(time()-start) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all_links = sum(all_links, []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install pipreqs | |
pipreqs /path/to/project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas | |
data = pandas.read_csv("test.csv", header=0) | |
col_a = list(data.a) | |
col_b = list(data.b) |
OlderNewer