If you can integrate $w(x)$ to give $W(x)=\int_0^x w(y)$ and then find an inverse of $W(x)$, you could chose your weighted random value to be $$W^{-1}\left(x\,W(1) \right)$$
If the calculations for that are too difficult then another approach, assuming that the weighting function $w(x)$ is bounded above by some known constant $b$, one approach might be:
1. Generate two uniform random numbers $x$ and $y$ on $[0,1)$
2. If $y \le \dfrac{w(x)}{b}$ then accept $x$ as the random value; otherwise repeat steps $1$ and $2$
The inefficiency of this algorithm depends on the relationship between $b$ and the expected value of $w(x)$