from bs4 import BeautifulSoup
import urllib2
import re
url = "http://blog.sina.com.cn/s/blog_53d7b5ce0100e7y0.html"
html_page = urllib2.urlopen(url)
soup = BeautifulSoup(html_page)
for link in soup.findAll('a'):
print link.get('href')
I want to save article url from the blog, stated in the ...
I am trying to create something that is very reusable here so that I can use it in other sites for other pages etc.
This code is for a simple photo gallery,
I took the code from here, but I changed it a bit and would like to add more functionality to it eventually, though.
PhotoGallery.ascx
<...
@nhgrif Indeed, but I have more positive feedback from players who played it on the youtube. But it would be a good thing to wait and see if things doesn't break like SimCity. I'm sure waiting 2 weeks is not a problem
@DanPantry hey long time no see!!! I think I am actually going to turn it into MVC, I just haven't gotten around to it yet. I know Web forms, hard to step out into the unknown, you know??
> Here we're nesting two loops. If our list has n items, our outer loop runs n times and our inner loop runs n times for each iteration of the outer loop, giving us n2 total prints. Thus this function runs in O(n2) time (or "quadratic time"). If the list has 10 items, we have to print 100 times. If it has 1,000 items, we have to print 1,000,000 times.
@DanPantry none taken, I know I need to learn more. I just gotta get somewhere where I can make some real money and don't have to work 2 jobs to stay afloat, so that I have time to study up on stuff....lol
@nhgrif I'm watching BDouble00 and traffic seems like it needs a fix. I don't know anything about traffic lights specifically, but that sorts of things doesn't worry me for a game, since it's patchable. But I won't buy it since I already have too much game to play.
a few people have advocated for property injection
I have argued that if I use property injection, and that remains null, then my logger will cause the rest of my business logic to crash and therefore it is not really suitable; if your class depends on the logger it should be put in the constructo
@Marc-Andre patch able, yes... But you can only patch something if you know how to fix it. Given how much of C:SL is copied directly from SC2013, they certainly knew traffic would be a major issue... And to me, traffic is most important aspect of a city builder. I'm not confident they know how to fix it and not sure I want to give them the benefit of the doubt.
But... Traffic lights should alleviate traffic problems, not create them. In my everyday life, I've never thought "this intersection would be better without a light," but I can think of 3 intersections in my city that would be better with a light.
I've never did a real Project Euler in my life, so I figured it was about to do one.
And what better Project Euler to start with than Problem 42?
Project description from Project Euler:
By converting each letter in a word to a number corresponding to its alphabetical position and adding the...
I have the following code in PHP that appends a file path with a timestamp of when it was last modified:
function AssetTimestamp($filename)
{
if (file_exists($filename)) {
return $filename . '?' . @filemtime($filename);
} else {
return $filename;
}
}
I have written ...
I've tried out a hybrid type of event management model, combining elements of the addEventListener-type and the onEvent-type. What I don't like about the addEventListener model is that you have to consult the documentation to choose the right event type, example: addEventListener("click", callbac...
I decided to write a small script to make writing html interactive stories less tedious.
import doctest
import re
import sys
import tkinter
import tkinter.filedialog
HTML_START = """<!DOCTYPE html>
<html lang="en">
<div align="center">
<head>
<title>{}</title>
<h1>{}</h1>
</head>
I have the following code:
if (isMandatory)
{
x.MandatoryServices.ForEach(y =>
{
if (!y.IsSelectedByUser)
{
containsRemovedSrvcs = true;
return;
}
});
}
else
{
x.OptionalServices.ForEach(y =>
{
...
First let me address why I'm not using the built-in string interning. My code is used in a utility that needs to free all of its memory once it's closed. Strings that are interned are not likely to be freed until the CLR is restarted. I can't cause that situation since my utility is used on serve...
Because your framework can put it in the constructor easier than it can do a setter, and it semantically makes more sense, uses less code and is easier to unit test
It makes sense, I was talking from a C# perspective, I didn't think you would be talking from a java perspective
Yeah, I agree thre, it does. it's not a perfect solution.
That's why I would suggest AOP/Attributes or IL weaving.
But I don't think that setLogger inherently helps you in reading things, to be honest.
Think about it, you'r reading code 6 months down the line. You look and say "oh, this logger is null. Where is it coming from?"
With setLogger you see "oh, crap. It could be coming from anywhere this object is found. That's not great. Now I have to go find everywhere setLogger is called and find out."
That's fine :-) I'm just enjoying the discussion of seeing someone else's viewpoint.
I just personally think that the constructor call is superior to property injection, but you're entitled to your opinion as well as me - neither of us are subjectively right or wrong
I have written a function which generates combinations of string by replacing 1 or more characters by the symbol "*".
The code is as follows:
/**
this following code is responsible to generate all possible combiantions of letters from a
word with *
for eg. word = "fin",...
It was setting up the p2p connection and retrieving the url to stream from (treat the p2p connection as some sort of vpn if it helps making sense, where I can ask things from localhost at the other side of the vpn, and I use that to get the proper IP address)
and managing the actual lower level recorder in that if it goes down, it does the things needed to get it back up
I have now split this in p2p connection setup and retrieving the url in one
and managing the lower level recorder in the other
and I don't have good names for them just yet, which is a really bad sign
eh whatever
screw splitting
it's 200 lines atm and not really gonna grow
Splitting would be good if I could toss one of the two away at some point in the process
I've just "finished" my second attempt a core game loop, which is a heavily refactored version of my first attempt.
My perceived benefits are:
Using functors means that the actual loops themselves are independent from the actual systems them manage. You can wrap states up elsewhere, and the on...