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
{ | |
"_id": "58744feda8aae907000d06c0", | |
"categories": [ | |
"55de81ac9d1fa51000f94770", | |
"55de81929d1fa51000f94769" | |
], | |
"coverImage": { | |
"_id": "588421e46ecf3a0700b7a31d", | |
"url": "https://hahow.in/images/588421e46ecf3a0700b7a31d" | |
}, |
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 requests | |
def get_web_page(url): | |
resp = requests.get( | |
url=url, | |
cookies={'over18': '1'} | |
) | |
if resp.status_code != 200: | |
print('Invalid url:', resp.url) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 requests | |
import json | |
import time | |
import numpy as np | |
import os | |
category = { | |
'55de818a9d1fa51000f94767': '生活', | |
'55de818d9d1fa51000f94768': '藝術', | |
'55de819a9d1fa51000f9476b': '運動', |
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
def getTopic(self, ai, imgtopic, Dict): | |
# JW: features 是準備要被預測 topic 的變數, 應該要挪到下方 prediction 開始前, 程式比較連貫 | |
#extrat the features of the element | |
features = str(re.sub(' +', ' ', ' '.join(self.extract_features(ai, imgtopic, Dict, 1)))) | |
#print (features) | |
# JW: 從這裡開始可以獨立切一個 function, 只呼叫一次, 把 train 好的 model 存起來 | |
#open training data file | |
current_dir = os.path.dirname(_file_) | |
corpus_dir = os.path.join(current_dir, 'corpus', 'all-corpus') |
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
""" | |
Extract features from htmls | |
""" | |
import sys, os, random, datetime | |
from bs4 import BeautifulSoup | |
# preprocess.py 檔案在這裡 |
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 django.http import HttpResponse | |
from django.shortcuts import get_object_or_404, render | |
from .models import Account, Client | |
def show(request): | |
uname = request.POST["uname"] | |
if "injection" in request.POST: | |
# Use raw SQL and string concatenation, resulting in SQL injection | |
accounts = Account.objects.raw(f'SELECT * FROM atm_account as a, atm_client as c WHERE a.client_id=c.id and c.username="{uname}"') | |
else: |
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 requests | |
import time | |
from bs4 import BeautifulSoup | |
import os | |
import re | |
import urllib.request | |
import json | |
PTT_URL = 'https://www.ptt.cc' |
OlderNewer