Example #1
0
def main():
#    lattice_type = str(input("Enter lattice type : "))
#    file_name = str(input("Enter file name as <filename.txt> : "))
#    max_distance = float(input("Enter max. points distance : "))
    lattice_type = 'bcc'
    elements = ['Ti', 'V'] #don't invert
    max_distance = 3.4
#    elements = ['V', 'Nb'] #invert
#    max_distance = 3.516063
#    elements = ['Ti', 'Zr']
#    max_distance = 3.758550
#    elements = ['Nb', 'Zr']
#    max_distance = 3.758550
    file_name = elements[0]+'_'+elements[1]+'.txt'
    
    
    #Parsing the above entered file to get the list of parameters for all 
    #structures.
    try:
        file_name = elements[0]+'_'+elements[1]+'.txt'
        structures_parameters_list = Parser.parse(lattice_type, file_name)
    except:
        file_name = elements[1]+'_'+elements[0]+'.txt'
        structures_parameters_list = Parser.parse(lattice_type, file_name)
    
    pure_element_0_min_energy, pure_element_1_min_energy = structure_helper.get_pure_energies(
            structures_parameters_list, elements)     
    
    #Storing map from structure name to structure object for easier access.
    structure_name_to_object_map = {}
    #Getting the list of all the structure objects.
    for parameters in structures_parameters_list:
        try:
            structure_object = structure(parameters, str(max_distance), 
                                         elements, pure_element_0_min_energy, 
                                         pure_element_1_min_energy)
            structure_name_to_object_map[structure_object.name_] = structure_object
        except:
            continue        
    
#    composition_ratio_to_structure_names_list_ = structure_helper.get_composition_ratio_to_structure_names_list_map(
#            structure_name_to_object_map.values())
    
#    Printing the structures
#    for structure_object in structure_name_to_object_map.values():
#        structure_object.print()

    convex_hull.draw(structure_name_to_object_map)
    
    model_train_object = model_train(structure_name_to_object_map)
Example #2
0
class API(Resource):
    """
        class API(Resource):
            REST класс для получения юморесок
            Имеет только метод get(), так как менять базу данных пользователь не может
    """
    def __init__(self):
        self.parser = Parser()

    def get(self, query=''):
        """
            def get(self, query=''): -> string, int
                Метод, выполняющий GET-запрос, а именно получение юморесок по запросу
                Возвращает строку с ответом и код ответа
        """
        print('url:', query)
        s = query.split('&')
        sort_arg = 'popularity'
        for i in s:
            if 'amount' in i:
                amount = i[7:]
            if 'sort_by' in i:
                sort_arg = i[8:]
        if query != '' and 'amount' in query:
            self.parser.create_query(query, amount, sort_arg)
            result = json.dumps(self.parser.get_jumoreski(),
                                ensure_ascii=False)
            return flask.make_response(result)
        elif query != '':
            self.parser.create_query(query, '1', sort_arg)
            result = json.dumps(self.parser.get_jumoreski(),
                                ensure_ascii=False)
            return flask.make_response(result)
        else:
            result = self.parser.get_random()
            return flask.make_response(json.dumps(result, ensure_ascii=False))
        return 'you picked the wrong house fool', 404
Example #3
0
from parser_class import Parser
import re
import time
import Trip_news_data as tnd
from bs4 import BeautifulSoup
import requests

parser1 = Parser('https://triptodream.ru/', 'newsTtD.txt', tnd.data[1], False)

reads1 = parser1.run()
news_actual = reads1[::]
print(reads1[0])
print(news_actual[0])
from parser_class import Parser

MY_PARSER = Parser()
file_name = input('File name : ')
MY_PARSER.parse(in_file_dir=file_name)
Example #5
0
 def __init__(self):
     self.parser = Parser()
Example #6
0
from parser_class import Parser

parser = Parser('https://quote.rbc.ru/?utm_source=topline', 'rbk_news.txt')
parser.run()
Example #7
0
from parser_class import Parser

parser = Parser('https://leninsk-kuz.ru/news/', 'new_news.txt')
parser.run()
Example #8
0
from parser_class import Parser
import re
import time
import Trip_news_data as tnd
from bs4 import BeautifulSoup
import requests

parser = Parser('https://vandrouki.ru/', 'newsVD.txt', tnd.data[0], False)

# url = 'https://vandrouki.ru/'
# print(parser.site['data'][0][0], parser.site['data'][0][1])
# results = []
# raw_html = requests.get(url)
# html = BeautifulSoup(raw_html.text, 'html.parser')

# news = html.find_all(parser.site['data'][0][0], parser.site['data'][0][1])
# # print(news)
# for item in news:
#     title = item.find(parser.site['data'][1][0],
#                       parser.site['data'][1][1]).get_text(strip=True)

#     results.append({
#         'title': title,
#     })
# print(results)
reads = parser.run()
news_actual = reads[::]
print(reads[0])
print(news_actual[0])
while True:
from parser_class import Parser

parser = Parser('https://www.ua-football.com/ua/sport', 'news.txt')
parser.run()
print(Parser.results)