我用Python3
和newspaper
库.据说这个库可以创建一个Source
对象,它是新闻网站的抽象.但是如果我只需要某个类别的抽象怎么办呢?
例如,当我使用这个网址时,我想获得该'technology'
类别的所有文章.相反,我从中获取文章'politics'
.
我认为在创建Source
对象时,报纸只使用域名,在我的例子中是这样www.kyivpost.com
.
有没有办法让它像网址一样工作http://www.kyivpost.com/technology/
?
我在 Python 2.7 上使用 Selenium 和 PhantomJS Webdriver,但在文档中没有看到任何有关清理缓存的参考。有没有办法清理缓存和cookie?我在 PhantomJS 中看到过可以做到这一点的函数,但是如何在 Selenium 中使用它们?
我正在尝试在我的 Vuejs 组件之一的“创建”生命周期挂钩中添加新变量、getter 和突变。变量工作正常。但是对于 getter/mutations,似乎并不像向 vuex 存储对象添加新函数那么容易。我试图解决的问题是创建“共享”可重用组件。
这是组件:
<template>
<div>
<h2 class="headline">Number of items:</h2>
<v-select
:items="limits"
item-value="value"
item-text="text"
label="Select"
v-model="selected_limit"/>
</div>
</template>
<script>
import {selectLimitComponentVariables} from './index';
import {selectLimitComponentGetters} from './getters';
import {selectLimitComponentMutations} from './mutations';
export default {
created: function () {
// Add the variables
Object.assign(this.$store.state[this.ns], selectLimitComponentVariables(this.var_prefix));
// Add the getters
Object.assign(this.$store.getters, selectLimitComponentGetters(this.ns, this.var_prefix));
// Add the mutations
Object.assign(this.$store._mutations, selectLimitComponentMutations(this.ns, this.var_prefix));
},
name: 'SelectLimitComponent',
props: {
ns: {
type: String,
default: null
},
var_prefix: {
type: String,
default: '' …
Run Code Online (Sandbox Code Playgroud) 浏览SheetJS 文档,我注意到支持导出到 csv 文件。我有工作代码,可以将对象数组转换为文件并开始下载:
let workSheet = XLSX.utils.json_to_sheet(rows);
let workBook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workBook, workSheet);
XLSX.writeFile(workBook, 'export.csv');
Run Code Online (Sandbox Code Playgroud)
但说到 tsv,只有一个将工作表转换为文本的示例:
> console.log(XLSX.utils.sheet_to_csv(ws, {FS:"\t"}));
S h e e t J S
1 2 3 4 5 6 7
2 3 4 5 6 7 8
Run Code Online (Sandbox Code Playgroud)
问题是,如何在文件中获得这种输出?
我知道如何获得指定电影的费用:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?item (GROUP_CONCAT( ?_cost; SEPARATOR = "~~~") AS ?budget)
WHERE {
VALUES ?selectedMovies { wd:Q24515019 wd:Q20762698 }
?item wdt:P31/wdt:P279* wd:Q11424 filter (?item = ?selectedMovies).
OPTIONAL {
?item wdt:P2130 ?_cost.
}
}
GROUP BY ?item
Run Code Online (Sandbox Code Playgroud)
但是当我尝试以成本换取货币时,我什么也没得到:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?item (GROUP_CONCAT( ?_cost; SEPARATOR = "~~~") AS ?budget)
(GROUP_CONCAT( ?_currency; SEPARATOR = "~~~") AS ?_currency)
WHERE {
VALUES ?selectedMovies { wd:Q24515019 wd:Q20762698 }
?item wdt:P31/wdt:P279* wd:Q11424 filter (?item = ?selectedMovies).
OPTIONAL {
?item wdt:P2130 ?_cost.
?_cost wdt:P2237 …
Run Code Online (Sandbox Code Playgroud) javascript ×2
python ×2
csv ×1
parsing ×1
phantomjs ×1
python-2.7 ×1
python-3.x ×1
selenium ×1
sheetjs ×1
sparql ×1
vue.js ×1
vuejs2 ×1
vuex ×1
web-scraping ×1
wikidata ×1