Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wkcn committed Feb 21, 2015
0 parents commit 9b4cb9b
Show file tree
Hide file tree
Showing 43 changed files with 3,331 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.pyc
*.user
*.suo
*.Debug
*.Release
*.tmp
old
release
debug
temp
55 changes: 55 additions & 0 deletions BingDict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-

import urllib,urllib2
from bs4 import BeautifulSoup
#import sys

#inputDecode = sys.stdin.encoding
#outputDecode = sys.stdout.encoding

def getHtml(word):
html = 'http://cn.bing.com/dict/search?&q=' + word
postdata = {'qs':'bs', 'form':'CM'}
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0',
'Host':'cn.bing.com',
'Referer':'http://cn.bing.com/dict/search',
}

request = urllib2.Request(url = html,
data = urllib.urlencode(postdata),
headers = headers)
wordHtml = urllib2.urlopen(request)
return wordHtml.read().decode('utf-8')

def BingDict(word):
try:
soup = BeautifulSoup(getHtml(word));
text = soup.find_all('span',{'class','def'})
ty = soup.find_all('span',{'class','pos'})
#res = []
#for i in range(len(text)):
# res.append((text[i].string,ty[i].string))
#return res
ans = ""
first = True
for i in range(len(text)):
if not first:
ans += '\n'
first = False
ans += ty[i].string+' '+text[i].string
#print type(ans)
return ans.encode('utf-8')#.decode('utf-8')
#for u in BingDict.BingDict(text):
# if not first:
# ans += '\n'
# first = False
# ans += u[1] + " " + u[0]

#.encode("utf-8")
except:
return ""


print BingDict('hello')
#http://cn.bing.com/dict/search?q=hello
Binary file added Defines.cpp
Binary file not shown.
50 changes: 50 additions & 0 deletions Defines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#ifndef DEFINES_H
#define DEFINES_H
#define _CRT_SECURE_NO_WARNINGS
#include <QMainWindow>
#include <QLabel>
#include <QFileDialog>
#include <QMessageBox>
#include <QTimer>
#include <QPainter>
#include <QApplication>
#include <QSharedMemory>
#include <QDesktopWidget>
#include <QMouseEvent>
#include <QProcess>
#include <QClipboard>
#include <QThread>

#include <Python.h>

#include <iostream>
#include <cstdlib>
#include <string>
#include <ctime>
#include <cmath>
#include <fstream>

using namespace std;
#pragma execution_character_set("utf-8")

struct SicilyConnect{
bool update;
int boxLife;
char text[512];
};

QDir directoryOf(const QString &subdir);
QString GetFileDir(QString file);

bool IsLeapYear(int year);
int YearHaveDay(int year);
int MonthHaveDay(int month,bool leap);

struct Date{
int year,month,day;
int hour,minute,second;
};

Date GetDate(int offsetHour = 0);

#endif
77 changes: 77 additions & 0 deletions GeneratedFiles/ui_mainwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/********************************************************************************
** Form generated from reading UI file 'mainwindow.ui'
**
** Created by: Qt User Interface Compiler version 5.3.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/

#ifndef UI_MAINWINDOW_H
#define UI_MAINWINDOW_H

#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QWidget>

QT_BEGIN_NAMESPACE

class Ui_MainWindow
{
public:
QWidget *centralWidget;
QLabel *sicily;
QLabel *eye;

void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QStringLiteral("MainWindow"));
MainWindow->setEnabled(true);
MainWindow->resize(300, 1080);
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(MainWindow->sizePolicy().hasHeightForWidth());
MainWindow->setSizePolicy(sizePolicy);
MainWindow->setMinimumSize(QSize(300, 1080));
MainWindow->setMaximumSize(QSize(300, 1080));
MainWindow->setToolTipDuration(-1);
MainWindow->setAnimated(false);
MainWindow->setUnifiedTitleAndToolBarOnMac(false);
centralWidget = new QWidget(MainWindow);
centralWidget->setObjectName(QStringLiteral("centralWidget"));
sicily = new QLabel(centralWidget);
sicily->setObjectName(QStringLiteral("sicily"));
sicily->setGeometry(QRect(0, 0, 300, 450));
sicily->setMouseTracking(false);
sicily->setScaledContents(false);
sicily->setWordWrap(false);
eye = new QLabel(centralWidget);
eye->setObjectName(QStringLiteral("eye"));
eye->setGeometry(QRect(0, 0, 300, 450));
MainWindow->setCentralWidget(centralWidget);

retranslateUi(MainWindow);

QMetaObject::connectSlotsByName(MainWindow);
} // setupUi

void retranslateUi(QMainWindow *MainWindow)
{
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "Sicily Chan", 0));
} // retranslateUi

};

namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui

QT_END_NAMESPACE

#endif // UI_MAINWINDOW_H
Loading

0 comments on commit 9b4cb9b

Please sign in to comment.