Main:
# $ begin
root_url = "http://hibernate.org/orm/downloads/"
html_cont = self.downloader.download(root_url)
new_data = self.parser_$.parse(root_url, html_cont, '')
self.outputer.collect_data(new_data)
# $ end
self.parser_$ = parser_$.HtmlParser()
import os
import bs4
import re
import urllib.parse
from bs4 import BeautifulSoup
class HtmlParser(object):
def _get_new_data(self, page_url, soup, final_str_name):
con_datas = []
res_data = {}
# url
res_data['url'] = page_url
res_data['name'] = '$'
# print("111111")
# print(con_data['name'])
# print("333333")
# print(con_data['cont'])
# print("222222")
return res_data, con_datas
def save_data(self, new_data, con_datas):
ret_data = {}
ret_data['name'] = new_data['name']
ret_data['url'] = new_data['url']
flag = 0
cont = ''
for data in con_datas:
# print(data['name'])
file_name = 'baike\Files\$\' + data['name'] + '.txt'
# print(file_name)
file_cont = data['cont']
# print(data['cont']+'fuck')
try:
if (os.path.exists(file_name)):
# print(file_name)
pass
else:
flag = flag + 1
cont = cont + ' Update %d: %s %s ' % (flag, data['name'], file_cont)
fout = open(file_name, 'w', encoding='utf-8')
fout.write(file_cont)
fout.close()
except:
pass
if flag == 0:
cont = cont + 'No Update Information! '
ret_data['cont'] = cont
return ret_data
pass
def parse(self, page_url, html_cont, final_str_name):
if page_url is None or html_cont is None:
return None, None
soup = BeautifulSoup(html_cont, 'html.parser')
new_data, con_datas = self._get_new_data(page_url, soup, final_str_name)
ret_data = self.save_data(new_data, con_datas)
return ret_data
pass
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
typedef unsigned long long LL ;
int main(){
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
char c;
string fuck = "hibernate";
cout<<fuck<<endl<<endl;
while(scanf("%c",&c)!=EOF){
if(c=='$'){
cout<<fuck;
}else{
cout<<c;
}
}
return 0;
}