Created
October 28, 2017 03:03
-
-
Save NuarkNoir/7cb0c05b3e11d3fcf24bedc4d3d2d9a7 to your computer and use it in GitHub Desktop.
Generating csv file(with name, cost, valute sign, etc.) from regru domains list
This file contains hidden or 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 bs4 import BeautifulSoup as bs | |
import requests | |
def main(): | |
print("Connecting to regru...") | |
url = "https://www.reg.ru/company/prices" | |
doc = bs(requests.get(url).content, "html5lib") | |
doms = doc.select("div.b-table-tlds__wrapper") | |
lists = doc.select("li.tooltip") | |
domensarray = [["Domain", "International", "Discount", "End price", "Valute"]] | |
print("Parsing data...") | |
for x in lists: | |
domstr = [] | |
domstr.append(x.select("span.b-table-tlds__name")[0].text) | |
discount = x.select("span.b-discount-flag__content") | |
if len(x.select("span.b-icon_label_idn")) >= 1: | |
domstr.append("IDN") | |
else: | |
domstr.append("NOT IDN") | |
if len(discount) >= 1: | |
domstr.append(discount[0].text) | |
else: | |
domstr.append("-0%") | |
price = str(x.select("span.b-table-tlds__price-wrapper")[0].text.split("\n").pop()) | |
valutesign = price.split().pop() | |
price = price.replace(valutesign, "") | |
domstr.append("".join(price.split())) | |
domstr.append(valutesign) | |
domensarray.append(domstr) | |
domencsv = open('./domen_prices.csv', 'w+') | |
print("Generating csv...") | |
for x in domensarray: | |
domencsv.write(", ".join(x) + "\n") | |
print("Done!") | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment