lecture11_practice
.html
keyboard_arrow_up
School
University of California, Davis *
*We aren’t endorsed by this school
Course
1
Subject
Computer Science
Date
Feb 20, 2024
Type
html
Pages
4
Uploaded by DukeFly4004
Practice: Find the most viral story
¶
The code below copies the code from today's demo.
Log into Reddit (PRAW)
¶
Our code starts with our Redddit PRAW setup:
In [13]:
import praw
import datetime
In [14]:
%run reddit_keys.py
In [15]:
# Give the praw code your reddit account info so
# it can perform reddit actions
reddit = praw.Reddit(
username=username, password=password,
client_id=client_id, client_secret=client_secret,
user_agent="a custom python script for user /" + str(username)
)
print(reddit.read_only)
reddit.read_only = True
False
Try to find the most viral story you can!
¶
In the code below, we're checking the "news" subreddit, for the top 10 ("limit=10") most hot (".hot") stories. But, we don't need to just do current hot stories; we have options! By replacing the hot() function with top(), rising(), or controversial() functions,
we can find the highest ranked posts (top), the posts that are gaining upvotes most quickly (rising), or the ones with the worst upvote/downvote ratios (controversial). These are all just different algorithms reddit uses to serve posts (more on that in the next lecture).
You also have options. The "limit" parameter tells the function how many posts to give us. We can also us the "time_filter" parameter, which accepts a string, to tell us what time period we want posts from.
For example, if we want the most 5 controversial posts of the year, we can do messages = reddit.subreddit("controversial").top(limit=5, time_filter="year"). The options for time_filter are "day", "week", "month", "year", and "all".
Modify the code below, and try to find the most viral news story you can!
In [16]:
# Look up the subreddit "cuteanimals", then find the "hot" list, getting up to 1 submission
messages = reddit.subreddit("news").hot(limit=10)
# get the first submission off the list (should only be one anyway)
messages_list = list(messages) for submission in messages_list:
# display the subject and body of the message, so we can see what we found
display("latest message subject: " + str(submission.title))
display("latest message body: " + str(submission.url))
display("latest message time: " +
str(datetime.datetime.fromtimestamp(submission.created_utc)))
duplicate_submissions = list(submission.duplicates(params={'crossposts_only': True,
'limit': 100}))
ordered_duplicate_submissions = sorted(
duplicate_submissions, key=lambda x: x.created_utc
)
print("duplicates:")
for duplicate_submission in ordered_duplicate_submissions:
print(" subreddit: " + str(duplicate_submission.subreddit))
print()
'latest message subject: FCC declares AI-generated voices in robocalls are illegal'
'latest message body: https://www.cbsnews.com/news/fcc-declares-robocalls-illegal/'
'latest message time: 2024-02-08 16:15:45'
duplicates:
subreddit: u_InterestingMemory325
'latest message subject: US court bans three weedkillers and finds EPA broke law in approval process'
'latest message body: https://www.theguardian.com/environment/2024/feb/07/us-
weedkiller-ban-dicamba-epa'
'latest message time: 2024-02-08 17:29:36'
duplicates:
subreddit: organic
subreddit: richguysayswords
subreddit: sdrawkcabtidder
"latest message subject: Sheriff: Camp not fully cooperating after apparent 'suspicious' death of 12-year-old"
'latest message body: https://wlos.com/news/local/trails-carolina-camp-not-fully-
cooperating-after-suspicious-death-of-12-year-old-boy-on-premesis-transylvania-sheriff-
chuck-owenby'
'latest message time: 2024-02-08 12:28:52'
duplicates:
subreddit: NorthCarolina
subreddit: sdrawkcabtidder
'latest message subject: 5 Marines aboard helicopter that went down outside San Diego are confirmed dead, military says'
'latest message body: https://apnews.com/article/marine-helicopter-found-san-diego-
mountains-a66c3e8565204c43a189301015ef41a6?
taid=65c4d18639616d00012c6c33&utm_campaign=TrueAnthem&utm_medium=AP&utm_source=Twitter'
'latest message time: 2024-02-08 13:18:39'
duplicates:
subreddit: PerpetualPixelNews
'latest message subject: Alabama station in disbelief after 200-foot radio tower stolen'
'latest message body: https://www.nbcnews.com/news/us-news/alabama-station-disbelief-
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
variants/3212612/take/5/
CATEGORY
Sort the items into whether they are benefits or risks of a search engine keeping a record
of your search history.
To place a category, press the item in the answer box, then press the box under the corre-
sponding category.
benefits
Add an answer item!
Answer Bank
risks
Add an answer item!
You can refer back to information you read earlier.
You can see which search result links you have not yet pressed.
A friend may see an embarrassing web search.
A family member may see an ad for a gift you secretly bought for them.
A related search will auto-complete so you do not need to type the whole thing.
Someone with access to search cata could create a scam related to your interests.
arrow_forward
add tags for these feature files with --tags option:
When you select scenarios by one tag
When you select scenarios that have one or another tag
When you select scenarios that have 2 tags
When you disable scenarios that have a specific tag
Given Scenarios:
Feature: Login functionalityBackground:Given a web browser is at the BrainBucket login pageScenario: user can't login without entering emailGiven User is not logged inWhen Password is enteredAnd User click Login buttonThen 'Warning: No match for E-Mail Address and/or Password' will be shownScenario: user can recover his passwordGiven User is not logged inWhen User clicks 'Forgotten Password' buttonAnd enters his emailThen Message 'An email with a confirmation link has been sent your email address.' will be dispalyed
arrow_forward
JavaScript triggers? It has a "onclick" function.
arrow_forward
3 DO NOT COPY FROM OTHER WEBSITES
Upvote guarenteed for a correct and detailed answer. Thank you!!!
arrow_forward
Your Word document contains a linked object. You plan to send a version of the document to your colleagues, but you do not want your colleagues to view subsequent updates to this file. Which method would be best to use?
Select one:
a.
Break the link
b.
Change the link source
c.
Set updates to automatic
d.
Set updates to manual
arrow_forward
Please write php code just
Thank you
arrow_forward
Html code for sure in this design java
.
arrow_forward
Lab 02: Splitting a URL into pieces
URLS are composed of five pieces:
The scheme, also known as the protocol
The authority (may further be divided into the user info, the host, and the port)
The path
The fragment identifier, also known as the section or ref
The query string
Read-only access to these parts of a URL is provided by nine public methods: getFile(), getHost(),
getPort(), getProtocol(), getRef(), getQuery(), getPath(), getUserinfo(), and getAuthority().
Write a Java program which uses these methods to split URLS entered on the command line into their
component parts.
arrow_forward
USE HTML, CSS AND JAVASCRIPT IN THIS
Question -
Create a Application that allows the user to customize the web page. Your design
must include CSS. The application should consists of three files as follows
a. Ask the user to login and read form the database to determine the
authentication. If the user is not known, the second file is loaded asking
the user to fill up the form to store personal data
b. Write a Java script to check the user is known user
c. Use cookies for storing the user details and display the user name when
the user moves on the next page.
arrow_forward
Create a Vaccination System using Php that has the following features:1. Add client record(such as firstname, lastname, middlename, category, address, date of first dose, date of second dose)
This is the answer they give it doesn't show anything. I attached a picture that shows the code's result below.
Everytime I ask a question they always answer this one but it doesn't show anything.
Please help
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
background-color: black;
}
* {
box-sizing: border-box;
}
.container {
padding: 16px;
background-color: white;
}
input[type=text], input[type=password] {
width: 100%;
padding: 15px;
margin: 5px 0 22px 0;
display: inline-block;
border: none;
background: #f1f1f1;
}
hr {
border: 1px solid #f1f1f1;
margin-bottom: 25px;
}
.registerbtn {
background-color: purple;
color: white;
padding: 16px 20px;
margin: 8px 0;
border: none;
cursor: pointer;…
arrow_forward
Create an anonymous block that returns the number of students in a section. Prompt for section id.B. Create an anonymous block that return the average numeric grade for a section. Prompt for sectionid and return the average grade.
arrow_forward
This is JavaScript programming. please help. provide step by step code.
arrow_forward
Create a login button on the index page and take the user to a login page. Prompt them for their username and password and compare it to the username and password stored for them in web storage. If it matches, display an alert that says "Logged In" If it does not match, display a message on the page that the username or password does not match and try again.
At the bottom of the login form, add a reset password link. Take the user to a reset password page that prompts them for their username and password and changes the password in web storage.
Existing Code:
Index.html
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Titan Sports Store</title>
<link rel="stylesheet" href="./css/style.css"></head><body><header>Titan Sports Store</header><div class="banner"><div…
arrow_forward
Answer please.
arrow_forward
JavaScript Dom Manipulation
Hi can anyone please help me fix my main.js file. We're not allowed to change anything in index.html. We have to make a button so that every time you click on it the count on the web page increases by one.
My code doesn't work and I don't know why. Every time I click the button, nothing happens. We just started learning about DOM and the only method we've learned so far is document.querySelector() Please help me understand dom events better. thank you so much!
var numTimesClicked = 0;
/* function handleClick(event) {
numTimesClicked++;
console.log('button clicked');
console.log('value of numTimesClicked:', numTimesClicked);
}
var $hot = document.querySelector('.hot-button');
var $click = document.querySelector('.click-count');
$click.addEventListener('click', handleClick); */
function handleClick(event) {
numTimesClicked++;
console.log('button clicked');
console.log('event:', event);
console.log('event.target', event.target);
}
var…
arrow_forward
JavaScript Dom Manipulation
Hi can anyone please help me fix my main.js file. We're not allowed to change anything in index.html. We have to make a button so that every time you click on it the count on the web page increases by one.
My code doesn't work and I don't know why. Every time I click the button, nothing happens. We just started learning about DOM and the only method we've learned so far is document.querySelector() Please help me understand dom events better. thank you so much!
main.js
var numTimesClicked = 0;
function handleClick(event) {
numTimesClicked++;
console.log('button clicked');
console.log('event:', event);
console.log('event.target', event.target);
}
var $click = document.querySelector('.click-count');
$click.addEventListener('click', handleClick);
function handleMouseover(event) {
console.log('button hovered');
console.log('event:', event);
console.log('event.target', event.target);
}
index.html
<!DOCTYPE html>
<html…
arrow_forward
DO NOT COPY FROM OTHER WEBSITES
Correct and detailed answer will be Upvoted else downvoted. Also explain why other options are FALSE. Thank you!
arrow_forward
Please write php and html code just
Thank you
arrow_forward
Links
2
Hyperlinks (links), are text or images you can click on a webpage that jump you to another page.
Anytime you use a website, you are using links to get from one page to the next. You can add a link
by using the anchor ( a ) tag.
In order to make your link work, you need to add an attribute to your a tag. An attribute is extra
information added to the inside of the opening tag to make it work properly. They follow this
general pattern:
For links, you need to add where the link goes using the href (hypertext reference) attribute. All
together your link should look something like this:
My Other Page
Let's try linking to the secondFile.html to see links in action!
Task
=
Add a link to secondFile.html around the "Click me" text in your paragraph, then try
clicking on your link!
arrow_forward
Question 1
What does the setData(newEmployees: List) method do in the Employees Adapter
It sets the data for all employees
O It adds a new employee to the RecyclerView
It removes all employees from the RecyclerView
It sets the data for a single employee
Question 2
Which of the following are valid item types that can be added to a RecyclerView?
Button
ImageView
CheckBox
TextView
Question 3
What is the purpose of the notifyDatasetChanged() method in a RecyclerView Adapter?
To inform the adapter that the underlying data has been changed and that the View should refresh itself
To add a new item to the RecyclerView
To remove an item from the RecyclerView
To change the layout of the RecyclerView
arrow_forward
Note:- Don't copy from other contents if any wrong i will downvote
arrow_forward
Q2
Every month there are millions of streamers
who stream in a variety of different categories.
for this challenge, you will be working on
writing a data structure that will be storing
the name of streamers streaming, the number
of views they currently have, as well as the
category they are streaming in
arrow_forward
The login.html image is shown below. The simple PHP module shows email and password fields for a user to enter. Analyze the code and identify one issue with the code regarding security. Explain the problem
by identifying the line no. and provide the corrected line of code.
login.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Login Form
Login
Email Address:
Password:
15
16
17
arrow_forward
A02-02
Create a webpage A2-Task2.html.
The webpage is displaying one image. Each time the user moves the mouse out of the image, the image is
changed to another one and one more 'sun' emoji is displayed under the image. When the number of 'suns'
reaches seven (7), all suns are deleted (reset) and start to be displayed again. For example, the 8th time user
moves the mouse out of the image, one 'sun' is shown, the 9th time - two 'suns', and so on.
Note:
- You should use two images. Each time the user moves the mouse out of the image, the image is changing. If
an image of "Winter" is displayed it will change to "Summer", and opposite, if an image of "Summer" is
displayed it will change to "Winter".
The special character code for the 'sun' is "☀".
-
Put the source code of your website A2-Task2.html here.
Make sure you also upload the A2-Task2.zip of all files below.
arrow_forward
Which attribute specifies where to open the link?
a. target
O b. _self
C.
_blank
d. href
arrow_forward
Hands-On Exercises #7 Superglobals $_GET and $_POST Source: Source: Connolly, R. and Hoar, R., (2018), Fundamentals of Web Development
Before you do the exercises
If you haven’t already done so, you should create a folder in your personal drive for all the exercises. This set of exercises requires a functioning webserver to interpret the PHP code.
Exercise 7-1 Checking for POST
1. 2.
Test lab7‐exercise7-1.php in a browser and notice that it contains a simple one field form that posts the results back to itself.
The first thing to do is detect whether the page was reached through a get (a link followed) or whether the page was arrived by the form being posted.
Edit the displayPostStatus() function as follows and test.
function displayPostStatus() {
if ($_SERVER["REQUEST_METHOD"] == "POST") { echo "Post detected";
} else {
echo "No Post Detected";
}
}
Now when you post the form you see the post detected, and when you enter the URL and hit enter (GET) it does not see the POST.
Next, let…
arrow_forward
Q1.
What should you use to access resources included in your Android project?
Q2.
Find two problems that prevent the following code from starting another Activity (ShowDetails) and passing the content of an edit text to it.
public void startNewActivity(View view) {
Intent i = new Intent(this, ShowDetails.class);
EditText msg= findViewById(R.id.msg_id);
i.putExtra("KEY", msg);
}
arrow_forward
common assessment-delivery/start/5581281388?action=onresume&submissionld-871222625
COURSES GROUPS RESOURCES GRADES
Checkpoint 3.1
To insert an equation or formula in a cell, start with the
Dollar ($)
Percent (%)
Equal (=)
hashtag (#)
sign.
Support | Schoology Blog | PF
arrow_forward
Question 13 sum.Full explain this question and text typing work only We should answer our question within 2 hours takes more time then we will reduce Rating Dont ignore this line
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Related Questions
- variants/3212612/take/5/ CATEGORY Sort the items into whether they are benefits or risks of a search engine keeping a record of your search history. To place a category, press the item in the answer box, then press the box under the corre- sponding category. benefits Add an answer item! Answer Bank risks Add an answer item! You can refer back to information you read earlier. You can see which search result links you have not yet pressed. A friend may see an embarrassing web search. A family member may see an ad for a gift you secretly bought for them. A related search will auto-complete so you do not need to type the whole thing. Someone with access to search cata could create a scam related to your interests.arrow_forwardadd tags for these feature files with --tags option: When you select scenarios by one tag When you select scenarios that have one or another tag When you select scenarios that have 2 tags When you disable scenarios that have a specific tag Given Scenarios: Feature: Login functionalityBackground:Given a web browser is at the BrainBucket login pageScenario: user can't login without entering emailGiven User is not logged inWhen Password is enteredAnd User click Login buttonThen 'Warning: No match for E-Mail Address and/or Password' will be shownScenario: user can recover his passwordGiven User is not logged inWhen User clicks 'Forgotten Password' buttonAnd enters his emailThen Message 'An email with a confirmation link has been sent your email address.' will be dispalyedarrow_forwardJavaScript triggers? It has a "onclick" function.arrow_forward
- 3 DO NOT COPY FROM OTHER WEBSITES Upvote guarenteed for a correct and detailed answer. Thank you!!!arrow_forwardYour Word document contains a linked object. You plan to send a version of the document to your colleagues, but you do not want your colleagues to view subsequent updates to this file. Which method would be best to use? Select one: a. Break the link b. Change the link source c. Set updates to automatic d. Set updates to manualarrow_forwardPlease write php code just Thank youarrow_forward
- Html code for sure in this design java .arrow_forwardLab 02: Splitting a URL into pieces URLS are composed of five pieces: The scheme, also known as the protocol The authority (may further be divided into the user info, the host, and the port) The path The fragment identifier, also known as the section or ref The query string Read-only access to these parts of a URL is provided by nine public methods: getFile(), getHost(), getPort(), getProtocol(), getRef(), getQuery(), getPath(), getUserinfo(), and getAuthority(). Write a Java program which uses these methods to split URLS entered on the command line into their component parts.arrow_forwardUSE HTML, CSS AND JAVASCRIPT IN THIS Question - Create a Application that allows the user to customize the web page. Your design must include CSS. The application should consists of three files as follows a. Ask the user to login and read form the database to determine the authentication. If the user is not known, the second file is loaded asking the user to fill up the form to store personal data b. Write a Java script to check the user is known user c. Use cookies for storing the user details and display the user name when the user moves on the next page.arrow_forward
- Create a Vaccination System using Php that has the following features:1. Add client record(such as firstname, lastname, middlename, category, address, date of first dose, date of second dose) This is the answer they give it doesn't show anything. I attached a picture that shows the code's result below. Everytime I ask a question they always answer this one but it doesn't show anything. Please help <!DOCTYPE html> <html> <head> <style> body { font-family: Arial, Helvetica, sans-serif; background-color: black; } * { box-sizing: border-box; } .container { padding: 16px; background-color: white; } input[type=text], input[type=password] { width: 100%; padding: 15px; margin: 5px 0 22px 0; display: inline-block; border: none; background: #f1f1f1; } hr { border: 1px solid #f1f1f1; margin-bottom: 25px; } .registerbtn { background-color: purple; color: white; padding: 16px 20px; margin: 8px 0; border: none; cursor: pointer;…arrow_forwardCreate an anonymous block that returns the number of students in a section. Prompt for section id.B. Create an anonymous block that return the average numeric grade for a section. Prompt for sectionid and return the average grade.arrow_forwardThis is JavaScript programming. please help. provide step by step code.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Np Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage