-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLLMB.qmd
113 lines (102 loc) · 2.59 KB
/
LLMB.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
title: "LLMB R package"
description: "Real-time Search Based on a Keyword "
date: last-modified
bibliography: references.bib
author:
- name: Xinzhuo Huang
orcid: 0009-0007-6448-5114
email: [email protected]
affiliations:
- name: HKUST SOSC
title-block-banner: "#8F999F"
citation:
author: Huang Xinzhuo
format:
html:
code-line-numbers: true
code-block-bg: true
code-block-border-left: "#ffffff"
code-tools:
caption: "Source Code"
smooth-scroll: true
linestretch: 1.2
df-print: paged
theme:
light: [flatly]
dark: [darkly]
code-fold: true
code-summary: "Show the R code"
toc: false
citation-location: margin
reference-location: margin
citations-hover: true
toc-location: right
number-sections: true
monofont: Georia
mainfont: Cambria Math
link-citations: yes
comments:
giscus:
repo: xinzhuohkust/comments
hypothesis:
theme: clean
execute:
warning: false
message: false
error: false
---
```{=html}
<style>
body {text-align: justify}
</style>
```
A package that allows political scientists to perform real-time searches on government responsiveness data within the [Local Leader Message Board](https://liuyan.people.com.cn/), a national platform for petitioning in China [@su2016selective]. Utilizing the `V8` package, this tool provides a JavaScript environment for [crypto-js](https://www.npmjs.com/package/crypto-js) within R, proving to be extremely helpful for reverse engineering during web scraping tasks. While currently a simple package, further development is underway to add advanced features such as additional data sources and visualization capabilities.
# Installation
```{r}
#| eval: false
#| code-fold: false
remotes::install_github("xinzhuohkust/LLMB")
library(LLMB)
```
# Usage
## Single keyword
```{r}
#| eval: false
#| code-fold: false
keyword_search(
keywords = "恒大",
page = 1,
rows = 10, # or 500
format = "tibble" # JSON or string
)
```
## Multi keywords
```{r}
#| eval: false
#| code-fold: false
tibble(
keywords = c("恒大", "碧桂园", "跑路")
) %>%
group_by(keywords) %>%
reframe(page = list(1:10)) %>%
unnest(page) %>%
mutate(
data = map2(
keywords,
page,
~ keyword_search(.x, .y, rows = 500),
.progress = TRUE
)
)
```
```{r}
#| echo: false
pacman::p_load(tidyverse, DT)
read_rds("sample_data/sample_data.Rds")
```
# Call `crypto-js` into R
```{r}
#| code-fold: false
cryptojs_env <- get(".cryptojs_env", envir = asNamespace("LLMB"))
```