Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs0a-24su
wikipedia
Commits
361e43e2
Commit
361e43e2
authored
11 months ago
by
Vansh V. Tibrewal
Browse files
Options
Download
Email Patches
Plain Diff
Account for special chars edge case in Wikipedia API
parent
3b7650c4
master
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/edu/caltech/cs0/wikipedia/libraries/Wikipedia.java
+2
-1
src/edu/caltech/cs0/wikipedia/libraries/Wikipedia.java
with
2 additions
and
1 deletion
+2
-1
src/edu/caltech/cs0/wikipedia/libraries/Wikipedia.java
View file @
361e43e2
...
...
@@ -5,6 +5,7 @@ import java.io.IOException;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
...
...
@@ -15,7 +16,7 @@ public class Wikipedia {
public
static
String
getPageText
(
String
title
)
{
try
{
URLConnection
u
=
new
URL
(
"https://"
+
SITE
+
"/w/api.php?action=parse&page="
+
title
.
replace
(
" "
,
"_"
)
+
"&prop=wikitext&format=xml"
"https://"
+
SITE
+
"/w/api.php?action=parse&page="
+
URLEncoder
.
encode
(
title
.
replace
(
" "
,
"_"
)
,
StandardCharsets
.
UTF_8
)
+
"&prop=wikitext&format=xml"
).
openConnection
();
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
u
.
getInputStream
(),
StandardCharsets
.
UTF_8
));
String
xmlPage
=
in
.
lines
().
collect
(
Collectors
.
joining
(
"\n"
));
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help