text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
on the burden of canonicalizing | 5,634.4 | 4.36 |
standardizing the data but being | 5,636.48 | 4.28 |
flexible with the users it's arguably a | 5,638.76 | 3.76 |
better user experience if you just let | 5,640.76 | 4.24 |
me copy paste or type in what I want you | 5,642.52 | 5.04 |
clean it up you're the programmer not me | 5,645 | 4.92 |
lenss for a better experience perhaps | 5,647.56 | 4.04 |
well let me go ahead and do this with | 5,649.92 | 3.799 |
twitter. let me first go ahead and | 5,651.6 | 5.079 |
prompt the user here for a value for a | 5,653.719 | 5.241 |
variable that I'll call URL and just ask | 5,656.679 | 4.44 |
them to input the URL of their Twitter | 5,658.96 | 3.88 |
profile I'm going to go ahead and strip | 5,661.119 | 3.56 |
off any leading or trailing whites space | 5,662.84 | 3.44 |
just in case users accidentally hit the | 5,664.679 | 3.04 |
space bar that's like literally the | 5,666.28 | 4.08 |
least I can do quite easily but now | 5,667.719 | 5.161 |
let's go ahead and do this suppose that | 5,670.36 | 6.839 |
the users's address is the following let | 5,672.88 | 6.08 |
me print out what they type in and let | 5,677.199 | 3.361 |
me clear my screen and run python of | 5,678.96 | 3.48 |
twitter. I'm going to go ahead and type | 5,680.56 | 4.04 |
in for instance | 5,682.44 | 3.799 |
https | 5,684.6 | 4.119 |
twitter.com davidj ma which happens to | 5,686.239 | 4.92 |
be my own Twitter username for now we're | 5,688.719 | 3.761 |
just going to print it back onto the | 5,691.159 | 2.881 |
screen just to make sure I've not messed | 5,692.48 | 3.84 |
up yet okay so I've printed back out the | 5,694.04 | 4.079 |
exact same URL but the goal at hand is | 5,696.32 | 5.52 |
to extract the username only now let me | 5,698.119 | 6.12 |
just ask perhaps a straightforward | 5,701.84 | 5.359 |
question logically what do I need to do | 5,704.239 | 6.92 |
to get at the user's username well uh we | 5,707.199 | 6.761 |
just ignore what's before the username | 5,711.159 | 5.361 |
and then just extract the username | 5,713.96 | 4.08 |
perfect yeah I mean it is as simple as | 5,716.52 | 3.24 |
that if you know the usernames at the | 5,718.04 | 3.92 |
end well let's just somehow ignore | 5,719.76 | 3.68 |
everything to the beginning well what's | 5,721.96 | 3.4 |
it beginning well it's a URL so we're | 5,723.44 | 3.56 |
probably going to need to ignore an | 5,725.36 | 6.52 |
https a colon a twitter.com and a slash | 5,727 | 6.52 |
so we just want to throw all of that | 5,731.88 | 4.52 |
away why because if it's URL We Know by | 5,733.52 | 4.56 |
how Twitter works that the username | 5,736.4 | 4.16 |
comes at the end so let's use that very | 5,738.08 | 5.039 |
simple idea to get at the information we | 5,740.56 | 3.8 |
want well I'm going to try this a few | 5,743.119 | 2.841 |
different ways let me go back into my | 5,744.36 | 2.64 |
program here and instead of just | 5,745.96 | 2.84 |
printing it out which was just to see | 5,747 | 4 |
what's going on let me do this let me | 5,748.8 | 4.48 |
create a new variable called username | 5,751 | 6.36 |
and let me call url. replace it turns | 5,753.28 | 7.32 |
out that if URL is a string or a stir in | 5,757.36 | 5.44 |
Python it again comes with multiple | 5,760.6 | 5.4 |
methods like strip uh and split and | 5,762.8 | 5.319 |
others as well one of which is called | 5,766 | 4.36 |
replace and replace will do just that | 5,768.119 | 4.201 |
you pass it two arguments the first of | 5,770.36 | 4.24 |
which is what do you want to replace the | 5,772.32 | 4.12 |
second argument is what do you want to | 5,774.6 | 4.039 |
replace it with so if I want to get rid | 5,776.44 | 3.96 |
of as I've been proposed really just | 5,778.639 | 3.321 |
everything before the username that is | 5,780.4 | 4.68 |
the Twitter URL or the beginning thereof | 5,781.96 | 6.56 |
let's just say this go ahead and replace | 5,785.08 | 5.52 |
https | 5,788.52 | 4.639 |
twitter.com close quote that's what I | 5,790.6 | 4.8 |
want to replace and comma second | 5,793.159 | 3.56 |
argument what do you want to replace it | 5,795.4 | 3.319 |
with nothing so I'm literally going to | 5,796.719 | 4.44 |
pass in quote unquote to effectively do | 5,798.719 | 4.241 |
a find and replace that's what the | 5,801.159 | 3.321 |
replace method does just like you can do | 5,802.96 | 3.279 |
it in Microsoft Word or Google Docs this | 5,804.48 | 3.719 |
is the programmer's way of doing find | 5,806.239 | 4.96 |
and replace now let me go ahead and | 5,808.199 | 5 |
print out just the username so I'll use | 5,811.199 | 4.601 |
an F string like this I'll say username | 5,813.199 | 4.881 |
colon and then in curly braces username | 5,815.8 | 4.359 |
just to format it nicely all right let | 5,818.08 | 3.559 |
me go ahead and clear my screen and run | 5,820.159 | 4.401 |
python of twitter. py enter URL here we | 5,821.639 | 3.881 |
go | 5,824.56 | 3.96 |
https | 5,825.52 | 3 |
twitter.com SL davidj maen enter okay | 5,828.56 | 7.079 |
now we've made some progress done for | 5,833.4 | 5.56 |
the day right well what is suboptimal | 5,835.639 | 6.04 |
about this can anyone critique or find | 5,838.96 | 6.8 |
fault with my program it is working now | 5,841.679 | 6.921 |
but it's a little fragile I bet we could | 5,845.76 | 4.76 |
contrive some scenarios where I think it | 5,848.6 | 4.2 |
works but it doesn't well I have a few | 5,850.52 | 5.04 |
ideas actually well first of all uh if | 5,852.8 | 6.399 |
we if we don't specify https it will | 5,855.56 | 6.72 |
broken secondly if we have slash at the | 5,859.199 | 6 |
end it also will be broken if we if we | 5,862.28 | 5.399 |
have like question mark something after | 5,865.199 | 5.201 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.